fix: 对接登出
This commit is contained in:
@@ -7,6 +7,7 @@ import { usePermissionStore } from '@/stores/permissionStore';
|
||||
import { useTabsStore } from '@/stores/tabsStore';
|
||||
import { useUserStore } from '@/stores/userStore';
|
||||
import { clearAuthDataCache } from '@/api/authCache';
|
||||
import { logout as logoutApi } from '@/api/login';
|
||||
import router from '@/router';
|
||||
|
||||
const TOKEN_KEY = 'MY_APP_AUTH_TOKEN';
|
||||
@@ -66,9 +67,14 @@ function createAuth() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 退出:清除 token → 清除菜单+权限 → 清除动态路由 → 跳转登录页
|
||||
* 退出:调用登出接口 → 清除 token → 清除菜单+权限 → 清除动态路由 → 跳转登录页
|
||||
*/
|
||||
const logout = () => {
|
||||
const logout = async () => {
|
||||
try {
|
||||
await logoutApi();
|
||||
} catch {
|
||||
// 即使接口失败也要继续清除本地会话
|
||||
}
|
||||
clearSession();
|
||||
router.push('/login');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user