diff --git a/ui/console-src/layouts/BasicLayout.vue b/ui/console-src/layouts/BasicLayout.vue index fa0f29e35..0eff4a660 100644 --- a/ui/console-src/layouts/BasicLayout.vue +++ b/ui/console-src/layouts/BasicLayout.vue @@ -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"; }, }); }; diff --git a/ui/src/locales/en.yaml b/ui/src/locales/en.yaml index 8250ab3ac..58b49521d 100644 --- a/ui/src/locales/en.yaml +++ b/ui/src/locales/en.yaml @@ -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: diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml index 7480986aa..0bf25ca63 100644 --- a/ui/src/locales/zh-CN.yaml +++ b/ui/src/locales/zh-CN.yaml @@ -26,6 +26,7 @@ core: logout: tooltip: 退出登录 title: 退出登录 + description: 点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。 profile: tooltip: 个人中心 visit_homepage: diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml index a68bac96b..62b745fcd 100644 --- a/ui/src/locales/zh-TW.yaml +++ b/ui/src/locales/zh-TW.yaml @@ -26,6 +26,7 @@ core: logout: tooltip: 登出 title: 登出 + description: 點擊確定將跳轉至退出登入頁面,請確保正在編輯的內容已保存。 profile: tooltip: 個人中心 visit_homepage: diff --git a/ui/uc-src/layouts/BasicLayout.vue b/ui/uc-src/layouts/BasicLayout.vue index f9ff9528b..87fd8af98 100644 --- a/ui/uc-src/layouts/BasicLayout.vue +++ b/ui/uc-src/layouts/BasicLayout.vue @@ -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"; }, }); };