瀏覽代碼

Поправлен баг вычисления rootRoute

Book Pauk 5 年之前
父節點
當前提交
d0891fb652
共有 2 個文件被更改,包括 16 次插入7 次删除
  1. 13 4
      client/components/App.vue
  2. 3 3
      client/components/Reader/Reader.vue

+ 13 - 4
client/components/App.vue

@@ -90,6 +90,18 @@ class App extends Vue {
         this.uistate = this.$store.state.uistate;
         this.uistate = this.$store.state.uistate;
         this.config = this.$store.state.config;
         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
         // set-app-title
         this.$root.$on('set-app-title', this.setAppTitle);
         this.$root.$on('set-app-title', this.setAppTitle);
 
 
@@ -178,10 +190,7 @@ class App extends Vue {
     }
     }
 
 
     get rootRoute() {
     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) {
     setAppTitle(title) {

+ 3 - 3
client/components/Reader/Reader.vue

@@ -302,8 +302,8 @@ class Reader extends Vue {
         (async() => {
         (async() => {
             await bookManager.init(this.settings);
             await bookManager.init(this.settings);
             bookManager.addEventListener(this.bookManagerEvent);
             bookManager.addEventListener(this.bookManagerEvent);
-            
-            if (this.$root.rootRoute == '/reader') {
+
+            if (this.$root.rootRoute() == '/reader') {
                 if (this.routeParamUrl) {
                 if (this.routeParamUrl) {
                     await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh});
                     await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh});
                 } else {
                 } else {
@@ -1086,7 +1086,7 @@ class Reader extends Vue {
     }
     }
 
 
     keyHook(event) {
     keyHook(event) {
-        if (this.$root.rootRoute == '/reader') {
+        if (this.$root.rootRoute() == '/reader') {
             let handled = false;
             let handled = false;
             if (!handled && this.helpActive)
             if (!handled && this.helpActive)
                 handled = this.$refs.helpPage.keyHook(event);
                 handled = this.$refs.helpPage.keyHook(event);