Эх сурвалжийг харах

Поправки багов, рефакторинг

Book Pauk 6 жил өмнө
parent
commit
a9fff6b6de
1 өөрчлөгдсөн 19 нэмэгдсэн , 12 устгасан
  1. 19 12
      client/components/App.vue

+ 19 - 12
client/components/App.vue

@@ -50,19 +50,13 @@ import Component from 'vue-class-component';
 
 export default @Component({
     watch: {
-        rootRoute: function(newValue) {
+        rootRoute: function() {
             this.setAppTitle();
-            if ((this.mode == 'reader' || this.mode == 'omnireader') && (newValue != '/reader')) {
-                //старый url
-                const search = window.location.search.substr(1);
-                const url = search.split('url=')[1] || '';
-                if (url) {
-                    window.location = `/#/reader?url=${url}`;
-                } else {
-                    this.$router.replace('/reader');
-                }
-            }
+            this.redirectIfNeeded();
         },
+        mode: function() {
+            this.redirectIfNeeded();
+        }
     },
 
 })
@@ -188,7 +182,7 @@ class App extends Vue {
     }
 
     get mode() {
-        return this.config.mode;
+        return this.$store.state.config.mode;
     }
 
     get showAsideBar() {
@@ -202,6 +196,19 @@ class App extends Vue {
     get showMain() {
         return (this.showAsideBar || this.isReaderActive);
     }
+
+    redirectIfNeeded() {
+        if ((this.mode == 'reader' || this.mode == 'omnireader') && (this.rootRoute != '/reader')) {
+            //старый url
+            const search = window.location.search.substr(1);
+            const url = search.split('url=')[1] || '';
+            if (url) {
+                window.location = `/#/reader?url=${url}`;
+            } else {
+                this.$router.replace('/reader');
+            }
+        }
+    }
 }
 //-----------------------------------------------------------------------------
 </script>