From 033be4f2d7a58204b35526e5624aef4c2b87ed9f Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sun, 11 Feb 2018 21:21:16 +0800 Subject: [PATCH] fix: onlyCover --- src/core/fetch/index.js | 11 ++++++----- src/core/render/index.js | 4 +++- src/themes/basic/_layout.css | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index ac1a908ed..7ee18cf8f 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -87,16 +87,17 @@ export function fetchMixin (proto) { path = cover === true ? '_coverpage' : cover } - this.coverEnable = !!path + const coverOnly = !!path && this.config.onlyCover if (path) { path = this.router.getFile(root + path) this.coverIsHTML = /\.html$/g.test(path) get(path + stringifyQuery(query, ['id']), false, requestHeaders).then( - text => this._renderCover(text) + text => this._renderCover(text, coverOnly) ) } else { - this._renderCover() + this._renderCover(null, coverOnly) } + return coverOnly } } @@ -106,9 +107,9 @@ export function fetchMixin (proto) { cb() } - this._fetchCover() + const onlyCover = this._fetchCover() - if (this.coverEnable && this.config.onlyCover) { + if (onlyCover) { done() } else { this._fetch(result => { diff --git a/src/core/render/index.js b/src/core/render/index.js index 33d9b3c45..382387dc6 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -134,8 +134,10 @@ export function renderMixin (proto) { }) } - proto._renderCover = function (text) { + proto._renderCover = function (text, coverOnly) { const el = dom.getNode('.cover') + + dom.toggleClass(dom.getNode('main'), coverOnly ? 'add' : 'remove', 'hidden') if (!text) { dom.toggleClass(el, 'remove', 'show') return diff --git a/src/themes/basic/_layout.css b/src/themes/basic/_layout.css index 91e75721a..4126a0ffa 100644 --- a/src/themes/basic/_layout.css +++ b/src/themes/basic/_layout.css @@ -223,6 +223,10 @@ main { z-index: 0; } +main.hidden { + display: none; +} + .anchor { display: inline-block; text-decoration: none;