This commit is contained in:
Rocky Kwok committed 2026-07-27 10:06:33 +08:00
commit fb73ae0471
220 files changed
+30857 -1735

No files matched your search

+42 -10
View File
@@ -71,6 +71,7 @@ function summarizeStoredUserInfo(): Record<string, unknown> | null {
const DEFAULT_USERNAME = 'guest';
const DEFAULT_REDIRECT_PATH = '/page/workspace/chats/new';
const FULL_CHAT_MODE = 'full';
type LoginStatus = 'loading' | 'success' | 'error';
@@ -91,10 +92,21 @@ export default function LoginPage() {
() => readEmbedParam(searchParams.toString()) === 'on',
[searchParams],
);
const isIframeLogin = useMemo(
() => isChatsIframeLogin(searchParams.toString()),
// Wujie is an application container, not the Brainy iframe protocol. It
// must therefore land on the regular full ChatPage even when an old portal
// URL still carries `from=iframe`. Plain embeds can request the same route
// explicitly with `chatMode=full`.
const fullChatRequested = useMemo(
() =>
isWujieEnv() ||
searchParams.get('chatMode')?.trim().toLowerCase() === FULL_CHAT_MODE,
[searchParams],
);
const isIframeLogin = useMemo(
() =>
!fullChatRequested && isChatsIframeLogin(searchParams.toString()),
[fullChatRequested, searchParams],
);
const resolvedUsername = useMemo(() => {
const raw = username?.trim();
return raw && raw.length > 0 ? raw : DEFAULT_USERNAME;
@@ -103,12 +115,20 @@ export default function LoginPage() {
// ticket/userId/env 仍按既有登录存储策略持久化。
const yUserId = searchParams.get('yUserId')?.trim() ?? '';
const redirectPath = useMemo(
() =>
resolvePostLoginRedirectPath(
() => {
if (yUserId) return GENERAL_QA_ROUTE;
// Keep the mode on the destination URL so PageRoutes can retain the
// full chat workspace sidebar while hideChrome hides only the global
// application chrome.
if (fullChatRequested) {
return `${DEFAULT_REDIRECT_PATH}?chatMode=${FULL_CHAT_MODE}`;
}
return resolvePostLoginRedirectPath(
searchParams.toString(),
yUserId ? GENERAL_QA_ROUTE : DEFAULT_REDIRECT_PATH,
),
[searchParams, yUserId],
DEFAULT_REDIRECT_PATH,
);
},
[fullChatRequested, searchParams, yUserId],
);
const toolToken = searchParams.get('token')?.trim() ?? '';
// 内网登录透传的访问令牌:存入 userInfo.accessToken,供 XK/PG 中任务 iframe 拼参
@@ -131,15 +151,27 @@ export default function LoginPage() {
// taskId,无需把它编进 redirect 值里。目标已自带的同名参数优先(不覆盖);登录鉴权类参数
// (token/authToken/ticket 等)一律**不透传**,避免泄漏到应用页地址栏。
const redirectTo = useMemo(() => {
const raw = searchParams.get('redirect')?.trim() ?? '';
const raw =
searchParams.get('redirect')?.trim() ||
searchParams.get('route')?.trim() ||
'';
if (!raw) return '';
if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || raw.startsWith('//') || raw.includes('\\')) return '';
const normalized = raw.startsWith('/') ? raw : `/${raw}`;
const [pathOnly, ownQuery = ''] = normalized.split('?');
const target = new URLSearchParams(ownQuery);
// Keep the Wujie/full-chat decision on the target URL. The destination
// route uses it to retain the full agent/history workspace sidebar.
if (
fullChatRequested &&
pathOnly === DEFAULT_REDIRECT_PATH &&
!target.has('chatMode')
) {
target.set('chatMode', FULL_CHAT_MODE);
}
// 登录流程自身消费的参数,不透传到目标页(尤以鉴权类为甚)。
const LOGIN_OWNED = new Set([
'redirect', 'ticket', 'userId', 'env', 'theme', 'yUserId',
'redirect', 'route', 'ticket', 'userId', 'env', 'theme', 'yUserId',
'token', 'access_token', 'password', 'authToken', 'goPath', 'from',
]);
new URLSearchParams(searchParams.toString()).forEach((value, key) => {
@@ -149,7 +181,7 @@ export default function LoginPage() {
});
const qs = target.toString();
return qs ? `${pathOnly}?${qs}` : pathOnly;
}, [searchParams]);
}, [fullChatRequested, searchParams]);
const externalParams = useMemo(
() => ({
theme: searchParams.get('theme') ?? '',