Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
董宏凯 committed 2026-07-27 19:19:01 +08:00
commit e496221dc3
6 files changed
+196 -37

No files matched your search

+9 -2
View File
@@ -8,6 +8,7 @@ import {
ShrinkIcon,
} from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
import { type PromptInputMessage } from "@/components/ai-elements/prompt-input";
import { useArtifacts } from "@/components/workspace/artifacts";
@@ -31,6 +32,7 @@ import { getAccessToken } from "@/core/auth";
import { useI18n } from "@/core/i18n/hooks";
import { useModels } from "@/core/models/hooks";
import { useNotification } from "@/core/notification/hooks";
import { buildChatsIframeThreadPath } from "@/core/page-layout/chats-iframe-route";
import { useRouteBase } from "@/core/route-base";
import {
isThreadRagModeLocked,
@@ -126,6 +128,7 @@ function postBrainyAuthToken(accessToken: string) {
export default function IframeChatPage() {
const routeBase = useRouteBase();
const location = useLocation();
const { t } = useI18n();
const [hasStartedConversation, setHasStartedConversation] = useState(false);
const { threadId, setThreadId, isNewThread, setIsNewThread, isMock } =
@@ -230,7 +233,11 @@ export default function IframeChatPage() {
history.replaceState(
null,
"",
`${window.location.pathname}${window.location.search}#${routeBase}/chats_iframe/${createdThreadId}`,
`${window.location.pathname}${window.location.search}#${buildChatsIframeThreadPath(
routeBase,
createdThreadId,
location.search,
)}`,
);
if (pendingRequestIdRef.current) {
@@ -707,4 +714,4 @@ export default function IframeChatPage() {
</ChatBox>
</ThreadContext.Provider>
);
}
}
+31 -20
View File
@@ -27,6 +27,10 @@ import {
persistAccessToken,
persistToolsToken,
} from '@/core/auth/yuser-login';
import {
isChatsIframeLogin,
resolvePostLoginRedirectPath,
} from '@/core/page-layout/chats-iframe-route';
import {
isSidebarEnabledFromSearch,
persistSidebarEnabled,
@@ -66,9 +70,7 @@ function summarizeStoredUserInfo(): Record<string, unknown> | null {
}
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';
@@ -100,26 +102,34 @@ export default function LoginPage() {
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;
},
const isIframeLogin = useMemo(
() =>
!fullChatRequested && isChatsIframeLogin(searchParams.toString()),
[fullChatRequested, searchParams],
);
const resolvedUsername = useMemo(() => {
const raw = username?.trim();
return raw && raw.length > 0 ? raw : DEFAULT_USERNAME;
}, [username]);
// 外部跳转参数:theme 直接调 setTheme;ticket/userId/env 持久化到 localStorage
// 外部跳转参数:普通登录的 theme 调 setTheme;iframe 登录由 forcedTheme 接管。
// ticket/userId/env 仍按既有登录存储策略持久化。
const yUserId = searchParams.get('yUserId')?.trim() ?? '';
const redirectPath = useMemo(
() => {
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(),
DEFAULT_REDIRECT_PATH,
);
},
[fullChatRequested, searchParams, yUserId],
);
const toolToken = searchParams.get('token')?.trim() ?? '';
// 内网登录透传的访问令牌:存入 userInfo.accessToken,供 XK/PG 中任务 iframe 拼参
const access_token = searchParams.get('access_token')?.trim() ?? '';
@@ -206,14 +216,14 @@ export default function LoginPage() {
// 主题切换:无界 props.theme 优先,其次 URL query theme。两者取值约定一致
// (dark-blue → 深色;red → 浅色;blue 暂无该主题,先用浅色代替),统一走 resolveThemeFromQuery。
// **嵌入模式跳过**:setTheme 会写 localStorage `strategy-theme`,跨标签污染正常系统页;
// 嵌入主题改由 forcedTheme(按标签页、不持久化)接管。
// **嵌入模式和 chats_iframe 登录跳过**:setTheme 会写 localStorage `strategy-theme`,
// 跨标签污染正常系统页;iframe 主题改由 forcedTheme(按标签页、不持久化)接管。
useEffect(() => {
if (isEmbed) return;
if (isEmbed || isIframeLogin) return;
const themeValue = wujieProps.theme || externalParams.theme;
if (!themeValue) return;
setTheme(resolveThemeFromQuery(themeValue));
}, [isEmbed, wujieProps.theme, externalParams.theme, setTheme]);
}, [isEmbed, isIframeLogin, wujieProps.theme, externalParams.theme, setTheme]);
// ticket / userId / env 持久化(与 login 请求并行做,互不阻塞)
useEffect(() => {
@@ -371,7 +381,7 @@ export default function LoginPage() {
}
}
router.replace(yUserId ? GENERAL_QA_ROUTE : redirectPath);
router.replace(redirectPath);
} catch (error) {
if (cancelled) {
return;
@@ -401,6 +411,7 @@ export default function LoginPage() {
taskId,
goPath,
redirectTo,
redirectPath,
isEmbed,
]);