代码提交

This commit is contained in:
董宏凯 committed 2026-07-24 11:24:11 +08:00
1 parent 28bf1ac7b2
commit 91ba47bf47
4 files changed
+55 -21

No files matched your search

+21 -5
View File
@@ -69,6 +69,7 @@ const DEFAULT_USERNAME = 'guest';
const IFRAME_LOGIN_SOURCE = 'iframe';
const DEFAULT_REDIRECT_PATH = '/page/workspace/chats/new';
const IFRAME_REDIRECT_PATH = '/page/workspace/chats_iframe/new';
const FULL_CHAT_MODE = 'full';
type LoginStatus = 'loading' | 'success' | 'error';
@@ -89,13 +90,28 @@ export default function LoginPage() {
() => readEmbedParam(searchParams.toString()) === 'on',
[searchParams],
);
const redirectPath = useMemo(
() =>
searchParams.get('from') === IFRAME_LOGIN_SOURCE
? IFRAME_REDIRECT_PATH
: DEFAULT_REDIRECT_PATH,
// External consumers may still send `from=iframe` for the legacy protocol
// chat. `chatMode=full` is an explicit escape hatch: always use the regular
// full ChatPage instead, which is the route expected by ordinary iframe
// nesting and browser deep links.
const fullChatRequested = useMemo(
() => searchParams.get('chatMode')?.trim().toLowerCase() === FULL_CHAT_MODE,
[searchParams],
);
const redirectPath = useMemo(
() => {
// 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 searchParams.get('from') === IFRAME_LOGIN_SOURCE
? IFRAME_REDIRECT_PATH
: DEFAULT_REDIRECT_PATH;
},
[fullChatRequested, searchParams],
);
const resolvedUsername = useMemo(() => {
const raw = username?.trim();
return raw && raw.length > 0 ? raw : DEFAULT_USERNAME;