mirror of https://github.com/halo-dev/halo
feat: add login expiration notification (#6738)
#### What type of PR is this? /area ui /kind improvement /milestone 2.20.x #### What this PR does / why we need it: 添加登录失效的引导。 <img width="1080" alt="image" src="https://github.com/user-attachments/assets/a84c0059-b0ef-4105-b8e9-ae6b3d39d89d"> #### Does this PR introduce a user-facing change? ```release-note None ```pull/6749/head
parent
db65dd3b3a
commit
e11a494c96
|
@ -1748,11 +1748,13 @@ core:
|
|||
titles:
|
||||
tip: Tip
|
||||
warning: Warning
|
||||
login_expired: Login expired
|
||||
descriptions:
|
||||
cannot_be_recovered: This operation is irreversible.
|
||||
editor_not_found: >-
|
||||
No editor found that matches the {raw_type} format. Please check if
|
||||
the editor plugin has been installed.
|
||||
login_expired: The current session has expired. Click Confirm to go to the login page. Please ensure that the current content is saved. You can click Cancel to manually copy any unsaved content.
|
||||
filters:
|
||||
results:
|
||||
keyword: "Keyword: {keyword}"
|
||||
|
|
|
@ -1635,9 +1635,11 @@ core:
|
|||
titles:
|
||||
tip: 提示
|
||||
warning: 警告
|
||||
login_expired: 登录已过期
|
||||
descriptions:
|
||||
cannot_be_recovered: 该操作不可恢复。
|
||||
editor_not_found: 未找到符合 {raw_type} 格式的编辑器,请检查是否已安装编辑器插件。
|
||||
login_expired: 当前登录已过期,点击确定跳转到登录页面,请确保当前内容已保存,你可以点击取消之后手动复制未保存的内容。
|
||||
filters:
|
||||
results:
|
||||
keyword: 关键词:{keyword}
|
||||
|
|
|
@ -1616,9 +1616,11 @@ core:
|
|||
titles:
|
||||
tip: 提示
|
||||
warning: 警告
|
||||
login_expired: 登入已過期
|
||||
descriptions:
|
||||
cannot_be_recovered: 該操作不可恢復。
|
||||
editor_not_found: 未找到符合 {raw_type} 格式的編輯器,請檢查是否已安裝編輯器插件。
|
||||
login_expired: 當前登入已過期,點擊確定跳轉到登入頁面,請確保當前內容已保存,你可以點擊取消之後手動複製未保存的內容。
|
||||
filters:
|
||||
results:
|
||||
keyword: 關鍵字:{keyword}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { i18n } from "@/locales";
|
||||
import { axiosInstance } from "@halo-dev/api-client";
|
||||
import { Toast } from "@halo-dev/components";
|
||||
import { Dialog, Toast } from "@halo-dev/components";
|
||||
import type { AxiosError } from "axios";
|
||||
|
||||
export interface ProblemDetail {
|
||||
|
@ -44,9 +44,22 @@ export function setupApiClient() {
|
|||
const { title, detail } = errorResponse.data;
|
||||
|
||||
if (status === 401) {
|
||||
Toast.warning(i18n.global.t("core.common.toast.login_expired"));
|
||||
|
||||
// TODO: show dialog
|
||||
Dialog.warning({
|
||||
title: i18n.global.t("core.common.dialog.titles.login_expired"),
|
||||
description: i18n.global.t(
|
||||
"core.common.dialog.descriptions.login_expired"
|
||||
),
|
||||
confirmType: "secondary",
|
||||
confirmText: i18n.global.t("core.common.buttons.confirm"),
|
||||
cancelText: i18n.global.t("core.common.buttons.cancel"),
|
||||
uniqueId: "login_expired",
|
||||
onConfirm: () => {
|
||||
const currentPath = `${location.pathname}${location.search}`;
|
||||
location.href = `/login?redirect_uri=${encodeURIComponent(
|
||||
currentPath
|
||||
)}`;
|
||||
},
|
||||
});
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue