浏览代码

fix 修复 手动登出与token过期登出跳转行为不一致问题

疯狂的狮子Li 1 年之前
父节点
当前提交
9dd7bf8990
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      src/layout/components/Navbar.vue

+ 9 - 2
src/layout/components/Navbar.vue

@@ -98,6 +98,7 @@ import { getTenantList } from '@/api/login';
 import { dynamicClear, dynamicTenant } from '@/api/system/tenant';
 import { TenantVO } from '@/api/types';
 import notice from './notice/index.vue';
+import router from "@/router";
 
 const appStore = useAppStore();
 const userStore = useUserStore();
@@ -163,8 +164,14 @@ const logout = async () => {
     cancelButtonText: '取消',
     type: 'warning'
   });
-  await userStore.logout();
-  location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
+  userStore.logout().then(() => {
+    router.replace({
+      path: '/login',
+      query: {
+        redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
+      }
+    })
+  });
 };
 
 const emits = defineEmits(['setLayout']);