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,
|
VTag,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { useEventListener } from "@vueuse/core";
|
import { useEventListener } from "@vueuse/core";
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
useOverlayScrollbars,
|
useOverlayScrollbars,
|
||||||
type UseOverlayScrollbarsParams,
|
type UseOverlayScrollbarsParams,
|
||||||
|
@ -42,24 +41,11 @@ const { currentRoles, currentUser } = storeToRefs(userStore);
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
Dialog.warning({
|
Dialog.warning({
|
||||||
title: t("core.sidebar.operations.logout.title"),
|
title: t("core.sidebar.operations.logout.title"),
|
||||||
|
description: t("core.sidebar.operations.logout.description"),
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
cancelText: t("core.common.buttons.cancel"),
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
window.location.href = "/logout";
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ core:
|
||||||
logout:
|
logout:
|
||||||
tooltip: Logout
|
tooltip: Logout
|
||||||
title: Logout
|
title: Logout
|
||||||
|
description: Clicking Confirm will redirect to the logout page. Please ensure that the content you are editing is saved.
|
||||||
profile:
|
profile:
|
||||||
tooltip: Profile
|
tooltip: Profile
|
||||||
visit_homepage:
|
visit_homepage:
|
||||||
|
|
|
@ -26,6 +26,7 @@ core:
|
||||||
logout:
|
logout:
|
||||||
tooltip: 退出登录
|
tooltip: 退出登录
|
||||||
title: 退出登录
|
title: 退出登录
|
||||||
|
description: 点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。
|
||||||
profile:
|
profile:
|
||||||
tooltip: 个人中心
|
tooltip: 个人中心
|
||||||
visit_homepage:
|
visit_homepage:
|
||||||
|
|
|
@ -26,6 +26,7 @@ core:
|
||||||
logout:
|
logout:
|
||||||
tooltip: 登出
|
tooltip: 登出
|
||||||
title: 登出
|
title: 登出
|
||||||
|
description: 點擊確定將跳轉至退出登入頁面,請確保正在編輯的內容已保存。
|
||||||
profile:
|
profile:
|
||||||
tooltip: 個人中心
|
tooltip: 個人中心
|
||||||
visit_homepage:
|
visit_homepage:
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
VAvatar,
|
VAvatar,
|
||||||
VTag,
|
VTag,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
useOverlayScrollbars,
|
useOverlayScrollbars,
|
||||||
type UseOverlayScrollbarsParams,
|
type UseOverlayScrollbarsParams,
|
||||||
|
@ -38,24 +37,11 @@ const { currentRoles, currentUser } = storeToRefs(userStore);
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
Dialog.warning({
|
Dialog.warning({
|
||||||
title: t("core.sidebar.operations.logout.title"),
|
title: t("core.sidebar.operations.logout.title"),
|
||||||
|
description: t("core.sidebar.operations.logout.description"),
|
||||||
confirmText: t("core.common.buttons.confirm"),
|
confirmText: t("core.common.buttons.confirm"),
|
||||||
cancelText: t("core.common.buttons.cancel"),
|
cancelText: t("core.common.buttons.cancel"),
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
window.location.href = "/logout";
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue