Bläddra i källkod

解决本地登录登出异常

Alfyn 2 veckor sedan
förälder
incheckning
bfe02737ff
3 ändrade filer med 15 tillägg och 6 borttagningar
  1. 5 2
      src/components/GlobalHeader/AvatarDropdown.vue
  2. 5 2
      src/permission.js
  3. 5 2
      src/views/exception/404.vue

+ 5 - 2
src/components/GlobalHeader/AvatarDropdown.vue

@@ -55,8 +55,11 @@ export default {
         content: this.$t('layouts.usermenu.dialog.content'),
         onOk: () => {
           return this.$store.dispatch('Logout').then(() => {
-            // this.$router.push({ name: 'login' })
-            window.location.href = "https://dev.autocde.com/login";
+            if(window.location.href.startsWith("http://localhost")){
+              this.$router.push({ name: 'login' })
+            }else{
+              window.location.href = "https://dev.autocde.com/login";
+            }
           })
         },
         onCancel () {}

+ 5 - 2
src/permission.js

@@ -127,8 +127,11 @@ router.beforeEach(async (to, from, next) => {
       // 在免登录名单,直接进入
       next()
     } else {
-      window.location.href = `https://dev.autocde.com/login?redirect=${to.fullPath}`;
-      // next({ path: loginRoutePath, query: { redirect: to.fullPath } })
+      if(window.location.href.startsWith("http://localhost")){
+        next({ path: '/user/login' })
+      }else{
+        window.location.href = `https://dev.autocde.com/login?redirect=${to.fullPath}`;
+      }
       NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
     }
   }

+ 5 - 2
src/views/exception/404.vue

@@ -26,8 +26,11 @@ export default {
         content: this.$t('layouts.usermenu.dialog.content'),
         onOk: () => {
           return this.$store.dispatch('Logout').then(() => {
-            // this.$router.push({ name: 'login' })
-            window.location.href = "https://dev.autocde.com/";
+            if(window.location.href.startsWith("http://localhost")){
+              this.$router.push({ name: 'login' })
+            }else{
+              window.location.href = "https://dev.autocde.com/login";
+            }
           })
         },
         onCancel () {}