refactor: 电商平台规格+市场语言改由 API 下发 (AGENTS.md 规则4完全合规)

This commit is contained in:
2026-06-17 18:37:26 +08:00
parent 22ef03839d
commit a0018353ec
3 changed files with 524 additions and 415 deletions
+38 -13
View File
@@ -20,6 +20,7 @@ import { toast } from "./components/toast/toastStore";
import { flushPendingGenerationRecords } from "./api/generationRecordClient";
import { keyServerClient } from "./api/keyServerClient";
import { preloadPublicConfig, getLogoUrl } from "./api/publicConfigClient";
import { preloadPlatformRules } from "./api/platformRulesClient";
import { setUserMaxConcurrency } from "./api/generationConcurrency";
import {
SERVER_SESSION_EXPIRED_EVENT,
@@ -156,6 +157,9 @@ function App() {
const [sessionNotice, setSessionNotice] = useState<string | null>(null);
const [profileMenuOpen, setProfileMenuOpen] = useState(false);
const [currentPage, setCurrentPage] = useState<"workspace" | "profile">("workspace");
// 平台规则 gating:数据就绪(或兜底超时)后才渲染 EcommercePage
// 保证其模块求值时 platformRulesClient 缓存已填充,拿到 API 数据。
const [platformRulesReady, setPlatformRulesReady] = useState(false);
const [workspaceChrome, setWorkspaceChrome] = useState<WorkspaceChromeState>({
isToolPage: false,
});
@@ -184,6 +188,20 @@ function App() {
initNotificationPermission();
}, []);
// 启动 gating:预加载平台规则。preload 自带超时+fallback 一定会 resolve
// 另加 3s 兜底,避免极端情况下首屏久等(兜底放行后用 fallback,数据=正确值)。
useEffect(() => {
let settled = false;
const markReady = () => {
if (settled) return;
settled = true;
setPlatformRulesReady(true);
};
void preloadPlatformRules().then(markReady, markReady);
const fallbackTimer = window.setTimeout(markReady, 3_000);
return () => window.clearTimeout(fallbackTimer);
}, []);
useEffect(() => {
if (!session) return;
void flushPendingGenerationRecords();
@@ -381,19 +399,26 @@ function App() {
</div>
}
>
<EcommercePage
projects={[]}
isAuthenticated={Boolean(session)}
onWorkspaceChromeChange={setWorkspaceChrome}
onStartCreate={() => undefined}
onOpenProject={() => undefined}
onDeleteProject={() => undefined}
onImportWorkflow={() => undefined}
onCreateTask={() => undefined}
onRequireLogin={() => openAuth("login")}
initialTemplate={null}
onInitialTemplateConsumed={() => undefined}
/>
{platformRulesReady ? (
<EcommercePage
projects={[]}
isAuthenticated={Boolean(session)}
onWorkspaceChromeChange={setWorkspaceChrome}
onStartCreate={() => undefined}
onOpenProject={() => undefined}
onDeleteProject={() => undefined}
onImportWorkflow={() => undefined}
onCreateTask={() => undefined}
onRequireLogin={() => openAuth("login")}
initialTemplate={null}
onInitialTemplateConsumed={() => undefined}
/>
) : (
<div className="page-loading-center">
<div className="page-loading-spinner" />
<span className="page-loading-center__text">...</span>
</div>
)}
</Suspense>
</ErrorBoundary>
</div>