From ac6ebb9e8daa11a050bd3a5d78bd1dd1fa8fb215 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 28 Oct 2020 23:41:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/App.vue | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index ac382f69..6f0b829c 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -38,7 +38,8 @@ class App extends Vue { '/sources': 'Источники', '/settings': 'Параметры', '/help': 'Справка', - } + }; + created() { this.commit = this.$store.commit; this.dispatch = this.$store.dispatch; @@ -54,10 +55,20 @@ class App extends Vue { cachedPath = this.$route.path; const m = cachedPath.match(/^(\/[^/]*).*$/i); cachedRoute = (m ? m[1] : this.$route.path); + } return cachedRoute; } + this.$router.beforeEach((to, from, next) => { + //распознавание хоста, если присутствует домен 3-уровня "b.", то разрешена только определенная страница + if (window.location.host.indexOf('b.') == 0 && to.path != '/external-libs' && to.path != '/404') { + next('/404'); + } else { + next(); + } + }); + // set-app-title this.$root.$on('set-app-title', this.setAppTitle); @@ -196,13 +207,6 @@ class App extends Vue { if ((this.mode == 'reader' || this.mode == 'omnireader' || this.mode == 'liberama.top')) { const search = window.location.search.substr(1); - //распознавание хоста, если присутствует домен 3-уровня "b.", то разрешена только определенная страница - if (window.location.host.indexOf('b.') == 0 && this.rootRoute != '/external-libs') { - this.$router.replace('/404'); - //чтобы ниоткуда нельзя было изменить путь (если какие-то страницы еще грузятся) - this.$router.push = this.$router.replace = null; - } - //распознавание параметра url вида "?url=" и редирект при необходимости if (!this.isReaderActive) { const s = search.split('url=');