From 00a699385ef676a92a22196fb22908261c8c1c91 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 4 Feb 2019 15:16:53 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BA=D1=86=D0=B8=D1=8E=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20undoAction=20,=20redoAct?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index 5624b6b2..a452a04c 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -147,6 +147,9 @@ class Reader extends Vue { showRefreshIcon = true; mostRecentBookReactive = null; + actionList = []; + actionCur = -1; + created() { this.loading = true; this.commit = this.$store.commit; @@ -165,6 +168,9 @@ class Reader extends Vue { const recent = this.mostRecentBook(); if (recent && recent.bookPos != newValue) { await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen})); + + if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue)) + this.addAction(newValue); } }, 500); @@ -247,6 +253,16 @@ class Reader extends Vue { return this.$store.state.reader.settings; } + addAction(pos) { + let a = this.actionList; + if (!a.length || a[a.length - 1] != pos) { + a.push(pos); + if (a.length > 20) + a.shift(); + this.actionCur = a.length - 1; + } + } + toolBarToggle() { this.commit('reader/setToolBarActive', !this.toolBarActive); this.$root.$emit('resize'); @@ -393,6 +409,18 @@ class Reader extends Vue { case 'loader': this.loaderToggle(); break; + case 'undoAction': + if (this.actionCur > 0) { + this.actionCur--; + this.bookPosChanged({bookPos: this.actionList[this.actionCur]}); + } + break; + case 'redoAction': + if (this.actionCur < this.actionList.length - 1) { + this.actionCur++; + this.bookPosChanged({bookPos: this.actionList[this.actionCur]}); + } + break; case 'fullScreen': this.fullScreenToggle(); break; @@ -442,6 +470,17 @@ class Reader extends Vue { break; } + switch (button) { + case 'undoAction': + if (this.actionCur <= 0) + classResult = classDisabled; + break; + case 'redoAction': + if (this.actionCur == this.actionList.length - 1) + classResult = classDisabled; + break; + } + if (this.activePage == 'LoaderPage' || !this.mostRecentBook()) { switch (button) { case 'undoAction': @@ -524,6 +563,9 @@ class Reader extends Vue { this.$nextTick(async() => { const progress = this.$refs.page; + this.actionList = []; + this.actionCur = -1; + try { progress.show(); progress.setState({state: 'parse'}); @@ -547,6 +589,7 @@ class Reader extends Vue { if (bookParsed) { await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(bookParsed))); this.mostRecentBook(); + this.addAction(bookPos); this.loaderActive = false; progress.hide(); this.progressActive = false; this.blinkCachedLoadMessage(); @@ -587,6 +630,7 @@ class Reader extends Vue { // добавляем в историю await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(addedBook))); this.mostRecentBook(); + this.addAction(bookPos); this.updateRoute(true); this.loaderActive = false;