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;