refactor(@vben/web-antd): 优化 logout功能
- 移除 logout函数的 redirect 参数 - 注释掉 redirect 相关的代码逻辑 - 更新调用 logout 函数的地方,移除参数传递
This commit is contained in:
parent
1a9351b176
commit
71590645cd
@ -13,6 +13,7 @@ import {
|
|||||||
} from '@vben/layouts';
|
} from '@vben/layouts';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import { useAccessStore, useUserStore } from '@vben/stores';
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
||||||
|
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
import LoginForm from '#/views/_core/authentication/login.vue';
|
import LoginForm from '#/views/_core/authentication/login.vue';
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ const roleDescription = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
await authStore.logout(false);
|
await authStore.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNoticeClear() {
|
function handleNoticeClear() {
|
||||||
|
@ -77,12 +77,12 @@ function setupAccessGuard(router: Router) {
|
|||||||
return {
|
return {
|
||||||
path: LOGIN_PATH,
|
path: LOGIN_PATH,
|
||||||
// 如不需要,直接删除 query
|
// 如不需要,直接删除 query
|
||||||
query:
|
// query:
|
||||||
to.fullPath === DEFAULT_HOME_PATH
|
// to.fullPath === DEFAULT_HOME_PATH
|
||||||
? {}
|
// ? {}
|
||||||
: { redirect: encodeURIComponent(to.fullPath) },
|
// : { redirect: encodeURIComponent(to.fullPath) },
|
||||||
// 携带当前跳转的页面,登录后重新跳转该页面
|
// 携带当前跳转的页面,登录后重新跳转该页面
|
||||||
replace: true,
|
// replace: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return to;
|
return to;
|
||||||
|
@ -86,7 +86,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout(redirect: boolean = true) {
|
async function logout() {
|
||||||
try {
|
try {
|
||||||
await logoutApi();
|
await logoutApi();
|
||||||
} catch {
|
} catch {
|
||||||
@ -98,11 +98,11 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
// 回登录页带上当前路由地址
|
// 回登录页带上当前路由地址
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: LOGIN_PATH,
|
path: LOGIN_PATH,
|
||||||
query: redirect
|
// query: redirect
|
||||||
? {
|
// ? {
|
||||||
redirect: encodeURIComponent(router.currentRoute.value.fullPath),
|
// redirect: encodeURIComponent(router.currentRoute.value.fullPath),
|
||||||
}
|
// }
|
||||||
: {},
|
// : {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user