From 67eb9316dce437440b6d6ff6504648e3243f8464 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 27 Jan 2019 11:59:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D1=86=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=B8=20=D1=81=D0=BE=D0=BE=D0=B1?= =?UTF-8?q?=D1=89=D0=B5=D0=B8=D1=8F=20=D0=B2=20=D1=81=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D1=83=D1=81=20=D0=B1=D0=B0=D1=80=D0=B5=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B5=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=B8=D0=B3=D0=B8=20=D0=B8=D0=B7=20=D0=BA=D0=B5=D1=88=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 40 ++++++++++++++++++- .../components/Reader/TextPage/TextPage.vue | 16 +++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index c115b0de..e642c9dc 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -30,7 +30,7 @@ - +
@@ -69,6 +69,7 @@ import ProgressPage from './ProgressPage/ProgressPage.vue'; import bookManager from './share/bookManager'; import readerApi from '../../api/reader'; +import {sleep} from '../../share/utils'; export default @Component({ components: { @@ -110,6 +111,7 @@ class Reader extends Vue { bookPos = null; allowUrlParamBookPos = true; + showRefreshIcon = true; created() { this.commit = this.$store.commit; @@ -326,6 +328,7 @@ class Reader extends Vue { this.commit('reader/setOpenedBook', Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(bookParsed))); this.loaderActive = false; progress.hide(); this.progressActive = false; + this.blinkCachedLoadMessage(); return; } @@ -346,10 +349,12 @@ class Reader extends Vue { progress.setState({totalSteps: 5}); // не удалось, скачиваем книгу полностью с конвертацией + let loadCached = true; if (!book) { book = await readerApi.loadBook(opts.url, (state) => { progress.setState(state); }); + loadCached = false; } // добавляем в bookManager @@ -364,6 +369,10 @@ class Reader extends Vue { this.loaderActive = false; progress.hide(); this.progressActive = false; + if (loadCached) { + this.blinkCachedLoadMessage(); + } else + this.stopBlink = true; } catch (e) { progress.hide(); this.progressActive = false; this.loaderActive = true; @@ -372,6 +381,31 @@ class Reader extends Vue { }); } + blinkCachedLoadMessage() { + this.blinkCount = 30; + if (!this.inBlink) { + this.inBlink = true; + this.stopBlink = false; + this.$nextTick(async() => { + let page = this.$refs.page; + while (this.blinkCount) { + this.showRefreshIcon = !this.showRefreshIcon; + if (page.blinkCachedLoadMessage) + page.blinkCachedLoadMessage(this.showRefreshIcon); + await sleep(500); + if (this.stopBlink) + break; + this.blinkCount--; + page = this.$refs.page; + } + this.showRefreshIcon = true; + this.inBlink = false; + if (page.blinkCachedLoadMessage) + page.blinkCachedLoadMessage('finish'); + }); + } + } + keyHook(event) { if (this.$root.rootRoute == '/reader') { let handled = false; @@ -468,4 +502,8 @@ i { width: 10px; display: inline-block; } + +.clear { + color: rgba(0,0,0,0); +} \ No newline at end of file diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index bdab682b..d37ee191 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -458,13 +458,27 @@ class TextPage extends Vue { i--; i = (i > lines.length - 1 ? lines.length - 1 : i); if (i >= 0) { + let message = this.statusBarMessage; + if (!message) + message = this.title; this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight, - lines[i].end, this.parsed.textLength, this.title); + lines[i].end, this.parsed.textLength, message); this.bookPosSeen = lines[i].end; } } } + blinkCachedLoadMessage(state) { + if (state === 'finish') { + this.statusBarMessage = ''; + } else if (state) { + this.statusBarMessage = 'Книга загружена из кеша'; + } else { + this.statusBarMessage = ' '; + } + this.drawStatusBar(); + } + async refreshTime() { if (!this.timeRefreshing) { this.timeRefreshing = true;