From d0891fb65239d30c4f430791eed47c9617ec27de Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 4 Feb 2020 16:29:10 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D0=B2=D1=8B=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20rootRoute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/App.vue | 17 +++++++++++++---- client/components/Reader/Reader.vue | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index f81b9f21..799234d1 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -90,6 +90,18 @@ class App extends Vue { this.uistate = this.$store.state.uistate; this.config = this.$store.state.config; + //root route + let cachedRoute = ''; + let cachedPath = ''; + this.$root.rootRoute = () => { + if (this.$route.path != cachedPath) { + cachedPath = this.$route.path; + const m = cachedPath.match(/^(\/[^/]*).*$/i); + cachedRoute = (m ? m[1] : this.$route.path); + } + return cachedRoute; + } + // set-app-title this.$root.$on('set-app-title', this.setAppTitle); @@ -178,10 +190,7 @@ class App extends Vue { } get rootRoute() { - const m = this.$route.path.match(/^(\/[^/]*).*$/i); - this.$root.rootRoute = (m ? m[1] : this.$route.path); - - return this.$root.rootRoute; + return this.$root.rootRoute(); } setAppTitle(title) { diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index b97aa182..cc2543cc 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -302,8 +302,8 @@ class Reader extends Vue { (async() => { await bookManager.init(this.settings); bookManager.addEventListener(this.bookManagerEvent); - - if (this.$root.rootRoute == '/reader') { + + if (this.$root.rootRoute() == '/reader') { if (this.routeParamUrl) { await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh}); } else { @@ -1086,7 +1086,7 @@ class Reader extends Vue { } keyHook(event) { - if (this.$root.rootRoute == '/reader') { + if (this.$root.rootRoute() == '/reader') { let handled = false; if (!handled && this.helpActive) handled = this.$refs.helpPage.keyHook(event);