import { lazy, type ReactNode, useEffect } from "react"; import { useLayoutMode } from "@/core/system-settings/hooks"; import { isEmbedActive, isHideChromeActive } from "@/core/embed/embed-session"; import { Navigate, Route, Routes, useLocation, useNavigate, useParams } from "react-router-dom"; import { toast } from "@/core/ui/feedback"; import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar"; import { WorkspaceSidebar } from "@/components/workspace/workspace-sidebar"; import { getAccountDisplayName, getStoredAuth } from "@/core/auth"; import { readTaskContext } from "@/core/auth/task-purpose"; import { persistCopTaskDetail, prefetchTaskDeeplink, resolveTaskDeeplinkTarget, stubCopTaskDetail, } from "@/core/auth/task-deeplink"; import { isSentimentAgentVisible } from "@/core/sentiment-agent/config"; import { RouteBaseProvider } from "@/core/route-base"; import "@/roundtable-planning/styles/roundtable-planning.css"; import { AGENT_MODULES } from "@/components/workspace/agents/agent-module-sidebar"; import { ChatRuntime } from "@/components/workspace/chat-runtime"; const AnalysisProjectsPage = lazy(() => import("./AnalysisProjectsPage")); const GeneralQA = lazy(() => import("@/strategy-components/components/chat-qa/GeneralQA")); const SentimentAnalyzes = lazy( () => import("@/strategy-components/components/task-components/SentimentAnalyzes"), ); const TaskManagement = lazy( () => import("@/strategy-components/components/task-components/TaskManagement"), ); const TaskPgFrom = lazy( () => import("@/strategy-components/components/task-components/TaskPgFrom"), ); const TaskTyFrom = lazy( () => import("@/strategy-components/components/task-components/TaskTyFrom"), ); const TaskXkFrom = lazy( () => import("@/strategy-components/components/task-components/TaskXkFrom"), ); const TaskAnalyzes = lazy( () => import("@/strategy-components/components/task-components/TaskAnalyzes"), ); const TaskFxWorkspace = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxWorkspace, })), ); const TaskFxIndexResolver = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxIndexResolver, })), ); const TaskFxChat = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxChat, })), ); const TaskBindChat = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskBindChat, })), ); const AgentFxWorkspace = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxWorkspace, })), ); const AgentFxIndexResolver = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxIndexResolver, })), ); const AgentFxChat = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxChat, })), ); const TaskAnalysisWorkspace = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisWorkspace, })), ); const TaskAnalysisIndexResolver = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisIndexResolver, })), ); const TaskAnalysisChat = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisChat, })), ); const ActionAnalyzes = lazy(() => import("@/strategy-components/components/task-components/ActionAnalyzes").then((module) => ({ default: module.ActionAnalyzes, })), ); const KnowledgeBaseResourceManagement = lazy( () => import("@/strategy-components/components/resource-management/KnowledgeBaseResourceManagement"), ); const NetworkActorResourceManagement = lazy( () => import("@/strategy-components/components/resource-management/NetworkActorResourceManagement"), ); const RoundtablePlanningPage = lazy( () => import("@/roundtable-planning/pages/RoundtablePlanningPage"), ); const PositionRoundtablePage = lazy( () => import("@/position-roundtable/pages/PositionRoundtablePage"), ); const EightBfRoundtablePage = lazy( () => import("@/eightbf-roundtable/pages/EightBfRoundtablePage"), ); const DashboardAgentPage = lazy( () => import("@/roundtable-planning/pages/DashboardAgentPage"), ); const DeepResearchPage = lazy(() => import("./DeepResearchPage")); const GongwenWorkbench = lazy(() => import("./deep-research/GongwenWorkbench")); const ReportStructureCreatePage = lazy( () => import("./deep-research/ReportStructureCreatePage"), ); const EnterpriseResearchPage = lazy(() => import("./EnterpriseResearchPage")); const BusinessChainListPage = lazy( () => import("@/roundtable-planning/pages/BusinessChainListPage"), ); const BusinessChainEditorPage = lazy( () => import("@/roundtable-planning/pages/BusinessChainEditorPage"), ); const AgentChatPage = lazy(() => import("./AgentChatPage")); const SentimentAgentChatPage = lazy(() => import("./SentimentAgentChatPage")); const AgentModuleRoutes = lazy(() => import("./AgentModulePage").then((module) => ({ default: module.AgentModuleRoutes })), ); const AgentsPage = lazy(() => import("./AgentsPage")); const AgentsPlazaPage = lazy(() => import("./AgentsPlazaPage")); const BusinessChainMappingPage = lazy(() => import("./BusinessChainMappingPage")); const ChatPage = lazy(() => import("./ChatPage")); const ChatsPage = lazy(() => import("./ChatsPage")); const AdminUserLeaderboardPage = lazy(() => import("./AdminUserLeaderboardPage")); const AdminUserLeaderboardSettingsPage = lazy( () => import("./AdminUserLeaderboardSettingsPage"), ); const PublicLeaderboardPage = lazy(() => import("./PublicLeaderboardPage")); const LightAppIframeView = lazy(() => import("./LightAppIframeView")); const LightAppListPage = lazy(() => import("./LightAppListPage")); const LightAppManagementPage = lazy(() => import("./LightAppManagementPage")); const MenuManagementPage = lazy(() => import("./MenuManagementPage")); const LoginWhitelistPage = lazy(() => import("./LoginWhitelistPage")); const FixedQuestionsPage = lazy(() => import("./FixedQuestionsPage")); const SensitiveWordsPage = lazy(() => import("./SensitiveWordsPage")); const SkillAddressesPage = lazy(() => import("./SkillAddressesPage")); const TaskButtonsPage = lazy(() => import("./TaskButtonsPage")); const HtmlTemplatesPage = lazy(() => import("./HtmlTemplatesPage")); const PositionRolesPage = lazy(() => import("./PositionRolesPage")); const RoundtableDiagnosticsPage = lazy(() => import("./RoundtableDiagnosticsPage")); const LightAppNewNotePage = lazy(() => import("./LightAppNewNotePage")); const LightAppNoteListPage = lazy(() => import("./LightAppNoteListPage")); const LightAppNoteQAPage = lazy(() => import("./LightAppNoteQAPage")); const NewAgentPage = lazy(() => import("./NewAgentPage")); const PromptPrefixSettingsPage = lazy(() => import("./PromptPrefixSettingsPage")); const PrivateSquareSettingsPage = lazy(() => import("./PrivateSquareSettingsPage")); const ModelConcurrencySettingsPage = lazy(() => import("./ModelConcurrencySettingsPage")); const RecommendedQuestionsPage = lazy(() => import("./RecommendedQuestionsPage")); const ScheduledTaskRunDetailPage = lazy(() => import("./ScheduledTaskRunDetailPage")); const ScheduledTasksPage = lazy(() => import("./ScheduledTasksPage")); const SkillEvolutionPage = lazy(() => import("./SkillEvolutionPage")); const SkillsPage = lazy(() => import("./SkillsPage")); const PositionsPage = lazy(() => import("./PositionsPage")); const TagsPage = lazy(() => import("./TagsPage")); const UsersPage = lazy(() => import("./UsersPage")); const LlmMetricsPage = lazy(() => import("./LlmMetricsPage")); const AdminScheduledTasksPage = lazy(() => import("./AdminScheduledTasksPage")); const AdminUserActivityPage = lazy(() => import("./AdminUserActivityPage")); const AdminAuditRetentionPage = lazy(() => import("./AdminAuditRetentionPage")); const StrategyProjectsPage = lazy( () => import("@/strategy-selection/StrategyProjectsPage"), ); const StrategySelectionPage = lazy( () => import("@/strategy-selection/StrategySelectionPage"), ); /** * Strategy's legacy `/chats/:thread_id` route shares ChatPage's header. * Unlike WorkspaceRoutes it did not render a WorkspaceSidebar, leaving the * header's expand/collapse control with no visible panel to operate. */ function StrategyChatThreadLayout() { return (
); } function StrategyProjectsLayout({ children }: { children: ReactNode }) { const [layoutMode] = useLayoutMode(); const showNavigation = layoutMode === "compact" && !isEmbedActive() && !isHideChromeActive(); return ( {showNavigation && } {showNavigation && (
)} {children}
); } function StrategyProjectWorkbenchRoute() { const { project_id: projectId = "" } = useParams<{ project_id: string }>(); return ; } /** * A custom business mapping's single-agent landing page. * * It intentionally has no task-workspace or agent-gallery left rail. The * deep-link target adds `hideChrome=1`, so PageLayout also suppresses the * global header and navigation sidebar for this clean entry surface. */ function CustomDeeplinkAgentChatRoute() { const { agent_id: agentId = "" } = useParams<{ agent_id: string }>(); const context = readTaskContext(); const chatBasePath = `/page/strategy/custom-deeplink/${encodeURIComponent(agentId)}/chats`; return ( ); } /** * 已登录用户的自定义业务深链入口。 * * 入口示例: * ``#/page/strategy/custom-deeplink-entry?goPath=区域研判&hideChrome=1``。 * 它不经过 LoginPage,因此不会清理或重新建立当前登录会话;解析成功后复用与登录 * 深链一致的任务上下文、智能体/业务链配置与无全局 chrome 的落地页。 */ function CustomDeeplinkEntryRoute() { const { search } = useLocation(); const navigate = useNavigate(); const query = new URLSearchParams(search); const taskId = query.get("taskId")?.trim() ?? ""; const goPath = query.get("goPath")?.trim() ?? ""; useEffect(() => { let cancelled = false; async function openDeeplink() { if (!goPath) { toast.error("缺少 goPath,无法打开自定义业务入口"); navigate("/page/strategy/qa/general", { replace: true }); return; } try { let resolvedTaskId = taskId; let detail = stubCopTaskDetail(taskId); if (taskId) { const prefetch = prefetchTaskDeeplink(taskId, goPath); resolvedTaskId = (await prefetch.realTaskId) || taskId; detail = (await prefetch.taskDetail) ?? stubCopTaskDetail(resolvedTaskId); persistCopTaskDetail(detail); } if (cancelled) return; const target = await resolveTaskDeeplinkTarget( goPath, detail, resolvedTaskId, taskId || undefined, ); if (cancelled) return; if (!target) { toast.error("未找到该自定义类型的智能体或业务链配置"); navigate("/page/strategy/qa/general", { replace: true }); return; } navigate(target.path, { replace: true, state: target.state }); } catch (error) { console.warn("[custom-deeplink-entry] resolve failed", { goPath, taskId, error }); if (cancelled) return; toast.error("自定义业务入口跳转失败"); navigate("/page/strategy/qa/general", { replace: true }); } } void openDeeplink(); return () => { cancelled = true; }; }, [goPath, navigate, taskId]); return (
正在打开业务入口…
); } export default function StrategyRoutes() { const storedAuth = getStoredAuth(); const canManageBusinessMappings = !storedAuth || storedAuth.system_role === "admin"; return (
} /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* 大屏绘制智能体独立页面(按 taskId 存取;ChatRuntime 提供 ArtifactsProvider 给沙箱预览) */} } /> {/* 需求 0616 #3/#4:zzJC / zzXD 「按类型聚合」模块页(重做,独立路由)。 */} } /> } /> }> } /> } /> } /> } /> } /> } /> } /> {/* 任务深链(3qfx / 3qfx-A):把智能体问答 / 会商嵌进 3QFX 业务上下文。 */} } /> {/* 三情分析:任务工作区(左对话列表 1:N,无目的树闸门;新建对话直接带开场信息)。 */} } > } /> } /> } /> {/* 任务深链(rwfx / rwfx-A):嵌进 任务FX 业务上下文。 */} } /> {/* 任务FX:任务工作区(左对话列表 1:N + 右问答;新建对话顶部目的树闸门)。 */} } > } /> } /> } /> {/* 任务深链(xdfx / xdfx-A):嵌进 XDFX 业务上下文。 */} } /> {/* 行动分析:任务工作区(左对话列表 1:N 精简版 + 左上行动详情卡片;直接问答, 右上角「开始回答」按钮手动发出开场信息,不走目的树闸门/覆盖确认)。 注意:xdfx 深链传入的是「行动id」,登录时已先经 resolveDeeplinkTaskId 换成任务id。 */} } > } /> } /> {/* 任务深链(agentfx):新系统 iframe 嵌入的智能体问答工作区(独立复制的 3qfx lite 版, 任务详情来自本系统 cop-task-detail;业务映射用 AFX 行,见 agentfx-deeplink)。 */} } > } /> } /> {/* b5-1:接入方先写入本系统详情,再由任务分析单智能体读取并问答。 */} } > } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* 舆情分析虚拟智能体:经 Gateway 转发外部 AG-UI 网关的专用对话页。 */} ) : ( ) } /> ) : ( ) } /> } /> } /> } /> } /> } /> } /> ) : ( ) } /> } /> } /> } /> } /> } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> ) : ( ) } /> } /> ) : ( ) } />
); }