feat: 公开嵌入页主题支持外部指定 + 排行榜入口移至左上角

- 公开页(/share、/public、/roundtable-share)新增 ?theme= 与
  deerflow:set-theme postMessage 两种外部主题指定方式,经
  usePublicEmbedTheme 接成 next-themes forcedTheme,不写 localStorage
- 排行榜入口从欢迎语旁移到 workspace-header 左上角应用名旁
- 新增 docs/embed-public-pages-theme.md 嵌入主题使用文档

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
吉鑫升andClaude Fable 5 committed 2026-06-12 15:12:17 +08:00
1 parent 57a87d6322
commit 81f2a48c6d
5 files changed
+245 -24

No files matched your search

+9 -1
View File
@@ -13,6 +13,7 @@ import {
resolveEmbedRoundtableTheme,
resolveEmbedTheme,
} from "@/core/embed/params";
import { usePublicEmbedTheme } from "@/core/embed/background";
import { readWujieProps } from "@/core/embed/wujie";
import { HashRouter, useLocation } from "react-router-dom";
@@ -31,9 +32,13 @@ import EmbedRoundtablePage from "./pages/EmbedRoundtablePage";
import { ChatRuntime } from "./pages/WorkspaceRoutes";
import { NotFoundPage } from "./pages/NotFoundPage";
// 公开页路由前缀:这些页面会被第三方 iframe 嵌入,主题可由外部指定。
const PUBLIC_EMBED_PREFIXES = ["/share/", "/public/", "/roundtable-share/"];
function AppProviders({ children }: { children: React.ReactNode }) {
const locale = useMemo(() => detectLocale(), []);
const location = useLocation();
const publicEmbedTheme = usePublicEmbedTheme();
// 嵌入路由的主题用 forcedTheme 强制:只影响当前渲染,不写 localStorage。
// 千万不要在嵌入页里调 ThemeContext.setTheme —— 它会持久化主题并打上
// 「用户已显式选择」标记。无界子应用与主站同域共享 localStorage,宿主
@@ -52,8 +57,11 @@ function AppProviders({ children }: { children: React.ReactNode }) {
const raw = new URLSearchParams(location.search).get("theme")?.trim();
return raw ? resolveEmbedTheme(raw) : undefined;
}
if (PUBLIC_EMBED_PREFIXES.some((p) => location.pathname.startsWith(p))) {
return publicEmbedTheme;
}
return undefined;
}, [location.pathname, location.search]);
}, [location.pathname, location.search, publicEmbedTheme]);
return (
<NextThemesProvider