fix(ui): 修复登录和并发请求并统一页面展示
调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
+16
-17
@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import { API, updateAPI } from './api';
|
||||
import { clearUserData, consumePostLoginRedirect, setUserData } from './data';
|
||||
import { showError, showSuccess } from './utils';
|
||||
import { showError } from './utils';
|
||||
|
||||
const SESSION_NOT_PERSISTED_MESSAGE =
|
||||
'登录成功但浏览器未能保存登录会话,请确认 Cookie 未被拦截后重试';
|
||||
@@ -35,8 +35,8 @@ export async function finishLogin({
|
||||
userDispatch,
|
||||
navigate,
|
||||
t = (s) => s,
|
||||
successMessage,
|
||||
redirectOverride,
|
||||
redirect,
|
||||
enterprise = false,
|
||||
}) {
|
||||
setUserData(data);
|
||||
// Recreate the axios instance so any in-flight request map from a prior
|
||||
@@ -49,7 +49,11 @@ export async function finishLogin({
|
||||
skipErrorHandler: true,
|
||||
disableDuplicate: true,
|
||||
});
|
||||
if (!res.data?.success || !res.data?.data) {
|
||||
if (
|
||||
!res.data?.success ||
|
||||
data?.id == null ||
|
||||
String(res.data?.data?.id) !== String(data.id)
|
||||
) {
|
||||
throw new Error(res.data?.message || 'session verify failed');
|
||||
}
|
||||
verifiedUser = res.data.data;
|
||||
@@ -64,18 +68,13 @@ export async function finishLogin({
|
||||
setUserData(verifiedUser);
|
||||
userDispatch({ type: 'login', payload: verifiedUser });
|
||||
|
||||
const message =
|
||||
successMessage === undefined ? t('登录成功!') : successMessage;
|
||||
if (message) {
|
||||
showSuccess(message);
|
||||
}
|
||||
// org_only(仅企业资源)用户默认落企业空间,与 AuthRedirect 一致:默认落地页
|
||||
// (密钥管理)挂载即调用被 BlockOrgOnlyMode 拦截的 /api/token,会先弹报错再被
|
||||
// orgConfined 踢回 /org;企业中心整体关闭时 orgConfined 不生效,会一直停在报错页
|
||||
const defaultRedirect =
|
||||
verifiedUser.org_only_mode === true ? '/org' : undefined;
|
||||
navigate(redirectOverride ?? consumePostLoginRedirect(defaultRedirect), {
|
||||
replace: true,
|
||||
});
|
||||
navigate(
|
||||
consumePostLoginRedirect({
|
||||
redirect,
|
||||
enterprise,
|
||||
orgOnly: verifiedUser.org_only_mode === true,
|
||||
}),
|
||||
{ replace: true },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user