fix: onlyCover

This commit is contained in:
qingwei.li 2018-02-11 21:21:16 +08:00 • committed by cinwell.li
commit 033be4f2d7
3 changed files with 13 additions and 6 deletions

View file

@ -87,16 +87,17 @@ export function fetchMixin (proto) {
path = cover === true ? '_coverpage' : cover path = cover === true ? '_coverpage' : cover
} }
this.coverEnable = !!path const coverOnly = !!path && this.config.onlyCover
if (path) { if (path) {
path = this.router.getFile(root + path) path = this.router.getFile(root + path)
this.coverIsHTML = /\.html$/g.test(path) this.coverIsHTML = /\.html$/g.test(path)
get(path + stringifyQuery(query, ['id']), false, requestHeaders).then( get(path + stringifyQuery(query, ['id']), false, requestHeaders).then(
text => this._renderCover(text) text => this._renderCover(text, coverOnly)
) )
} else { } else {
this._renderCover() this._renderCover(null, coverOnly)
} }
return coverOnly
} }
} }
@ -106,9 +107,9 @@ export function fetchMixin (proto) {
cb() cb()
} }
this._fetchCover() const onlyCover = this._fetchCover()
if (this.coverEnable && this.config.onlyCover) { if (onlyCover) {
done() done()
} else { } else {
this._fetch(result => { this._fetch(result => {

View file

@ -134,8 +134,10 @@ export function renderMixin (proto) {
}) })
} }
proto._renderCover = function (text) { proto._renderCover = function (text, coverOnly) {
const el = dom.getNode('.cover') const el = dom.getNode('.cover')
dom.toggleClass(dom.getNode('main'), coverOnly ? 'add' : 'remove', 'hidden')
if (!text) { if (!text) {
dom.toggleClass(el, 'remove', 'show') dom.toggleClass(el, 'remove', 'show')
return return

View file

@ -223,6 +223,10 @@ main {
z-index: 0; z-index: 0;
} }
main.hidden {
display: none;
}
.anchor { .anchor {
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;