Merge branch 'fork/kuchaguangjie/fix'
This commit is contained in:
@@ -78,15 +78,22 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isLoggingOut = ref(false); // 正在 logout 标识, 防止 /logout 死循环.
|
||||||
|
|
||||||
async function logout(redirect: boolean = true) {
|
async function logout(redirect: boolean = true) {
|
||||||
|
if (isLoggingOut.value) return; // 正在登出中, 说明已进入循环, 直接返回.
|
||||||
|
isLoggingOut.value = true; // 设置 标识
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await logoutApi();
|
await logoutApi();
|
||||||
} catch {
|
} catch {
|
||||||
// 不做任何处理
|
// 不做任何处理
|
||||||
}
|
} finally {
|
||||||
|
isLoggingOut.value = false; // 重置 标识
|
||||||
|
|
||||||
resetAllStores();
|
resetAllStores();
|
||||||
accessStore.setLoginExpired(false);
|
accessStore.setLoginExpired(false);
|
||||||
|
}
|
||||||
|
|
||||||
// 回登录页带上当前路由地址
|
// 回登录页带上当前路由地址
|
||||||
await router.replace({
|
await router.replace({
|
||||||
|
|||||||
Reference in New Issue
Block a user