mirror of https://github.com/halo-dev/halo
fix: resolve issue with logout functionality in Console not working (#6766)
#### What type of PR is this? /area ui /kind bug /milestone 2.20.x #### What this PR does / why we need it: 修复 Console 中退出登录功能失效的问题。 #### Which issue(s) this PR fixes: Fixes #6756 #### Does this PR introduce a user-facing change? ```release-note None ```pull/6769/head^2
parent
8896e16615
commit
b0ad0406b9
|
@ -17,7 +17,6 @@ import {
|
|||
VTag,
|
||||
} from "@halo-dev/components";
|
||||
import { useEventListener } from "@vueuse/core";
|
||||
import axios from "axios";
|
||||
import {
|
||||
useOverlayScrollbars,
|
||||
type UseOverlayScrollbarsParams,
|
||||
|
@ -42,24 +41,11 @@ const { currentRoles, currentUser } = storeToRefs(userStore);
|
|||
const handleLogout = () => {
|
||||
Dialog.warning({
|
||||
title: t("core.sidebar.operations.logout.title"),
|
||||
description: t("core.sidebar.operations.logout.description"),
|
||||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await axios.post(`/logout`, undefined, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
await userStore.fetchCurrentUser();
|
||||
|
||||
// Clear csrf token
|
||||
document.cookie =
|
||||
"XSRF-TOKEN=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
||||
|
||||
window.location.href = "/login";
|
||||
} catch (error) {
|
||||
console.error("Failed to logout", error);
|
||||
}
|
||||
window.location.href = "/logout";
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@ core:
|
|||
logout:
|
||||
tooltip: Logout
|
||||
title: Logout
|
||||
description: Clicking Confirm will redirect to the logout page. Please ensure that the content you are editing is saved.
|
||||
profile:
|
||||
tooltip: Profile
|
||||
visit_homepage:
|
||||
|
|
|
@ -26,6 +26,7 @@ core:
|
|||
logout:
|
||||
tooltip: 退出登录
|
||||
title: 退出登录
|
||||
description: 点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。
|
||||
profile:
|
||||
tooltip: 个人中心
|
||||
visit_homepage:
|
||||
|
|
|
@ -26,6 +26,7 @@ core:
|
|||
logout:
|
||||
tooltip: 登出
|
||||
title: 登出
|
||||
description: 點擊確定將跳轉至退出登入頁面,請確保正在編輯的內容已保存。
|
||||
profile:
|
||||
tooltip: 個人中心
|
||||
visit_homepage:
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
VAvatar,
|
||||
VTag,
|
||||
} from "@halo-dev/components";
|
||||
import axios from "axios";
|
||||
import {
|
||||
useOverlayScrollbars,
|
||||
type UseOverlayScrollbarsParams,
|
||||
|
@ -38,24 +37,11 @@ const { currentRoles, currentUser } = storeToRefs(userStore);
|
|||
const handleLogout = () => {
|
||||
Dialog.warning({
|
||||
title: t("core.sidebar.operations.logout.title"),
|
||||
description: t("core.sidebar.operations.logout.description"),
|
||||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await axios.post(`/logout`, undefined, {
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
await userStore.fetchCurrentUser();
|
||||
|
||||
// Clear csrf token
|
||||
document.cookie =
|
||||
"XSRF-TOKEN=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
||||
|
||||
window.location.href = "/login";
|
||||
} catch (error) {
|
||||
console.error("Failed to logout", error);
|
||||
}
|
||||
window.location.href = "/logout";
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue