@lobehub/lobehub 2.0.0-next.72 → 2.0.0-next.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/desktop-pr-build.yml +7 -3
- package/CHANGELOG.md +50 -0
- package/apps/desktop/package.json +1 -0
- package/apps/desktop/src/main/controllers/LocalFileCtr.ts +55 -11
- package/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts +153 -0
- package/changelog/v1.json +18 -0
- package/locales/en-US/tool.json +12 -1
- package/locales/zh-CN/tool.json +12 -1
- package/next.config.ts +5 -5
- package/package.json +2 -1
- package/packages/electron-client-ipc/src/types/localSystem.ts +4 -0
- package/scripts/prebuild.mts +16 -6
- package/src/app/(backend)/trpc/desktop/[trpc]/route.ts +6 -6
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/UserBanner.test.tsx +7 -4
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +4 -4
- package/src/app/[variants]/(main)/(mobile)/me/(home)/features/UserBanner.tsx +5 -6
- package/src/app/[variants]/(main)/(mobile)/me/(home)/features/useCategory.tsx +5 -8
- package/src/app/[variants]/(main)/(mobile)/me/(home)/index.tsx +25 -0
- package/src/app/[variants]/(main)/(mobile)/me/(home)/layout.tsx +13 -16
- package/src/app/[variants]/(main)/(mobile)/me/profile/features/Category.tsx +6 -6
- package/src/app/[variants]/(main)/(mobile)/me/profile/features/Header.tsx +3 -3
- package/src/app/[variants]/(main)/(mobile)/me/profile/index.tsx +16 -0
- package/src/app/[variants]/(main)/(mobile)/me/profile/layout.tsx +9 -11
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/Header.tsx +3 -3
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +3 -4
- package/src/app/[variants]/(main)/(mobile)/me/settings/index.tsx +16 -0
- package/src/app/[variants]/(main)/(mobile)/me/settings/layout.tsx +15 -13
- package/src/app/[variants]/(main)/changelog/_layout/Desktop/index.tsx +6 -5
- package/src/app/[variants]/(main)/changelog/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/changelog/_layout/Mobile/index.tsx +5 -5
- package/src/app/[variants]/(main)/changelog/features/Post.tsx +7 -4
- package/src/app/[variants]/(main)/changelog/index.tsx +55 -0
- package/src/app/[variants]/(main)/chat/_layout/Desktop/index.tsx +6 -7
- package/src/app/[variants]/(main)/chat/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/chat/components/WorkspaceLayout.tsx +1 -14
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatHydration/index.tsx +2 -2
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/Desktop/MessageFromUrl.tsx +11 -13
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/Desktop/index.tsx +0 -1
- package/src/app/[variants]/(main)/chat/components/conversation/features/ThreadHydration.tsx +2 -2
- package/src/app/[variants]/(main)/chat/components/topic/features/Topic/TopicListContent/TopicItem/TopicContent.tsx +20 -11
- package/src/app/[variants]/(main)/chat/features/PageTitle/index.tsx +1 -2
- package/src/app/[variants]/(main)/chat/index.tsx +29 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionHydration.tsx +8 -6
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/Inbox/index.tsx +2 -4
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/index.tsx +1 -1
- package/src/app/[variants]/(main)/chat/session/layout/Mobile/SessionHeader.tsx +3 -3
- package/src/app/[variants]/(main)/chat/settings/_layout/Desktop/Header.tsx +3 -3
- package/src/app/[variants]/(main)/chat/settings/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/chat/settings/features/PublishResultModal/index.tsx +3 -3
- package/src/app/[variants]/(main)/chat/{components/SettingsPage.tsx → settings/index.tsx} +6 -35
- package/src/app/[variants]/(main)/components/Link.tsx +21 -0
- package/src/app/[variants]/(main)/discover/(detail)/_layout/{Desktop.tsx → Desktop/index.tsx} +15 -7
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Mobile/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/Block.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Overview/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/SystemRole/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Versions/index.tsx +4 -4
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Header.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/ActionButton/AddAgent.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/ActionButton/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/Related/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/TocList/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/StatusPage/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/assistant/{AssistantDetailPage.tsx → index.tsx} +18 -11
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Details/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Details/Versions/index.tsx +5 -5
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Details/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/ServerConfig.tsx +4 -4
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/TocList/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/mcp/{McpDetailPage.tsx → index.tsx} +15 -7
- package/src/app/[variants]/(main)/discover/(detail)/mcp/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Overview/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Parameter/ParameterItem.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Header.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/ActionButton/ChatWithModel.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/ActionButton/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/RelatedProviders/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/{ModelDetailPage.tsx → index.tsx} +17 -10
- package/src/app/[variants]/(main)/discover/(detail)/model/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/ActionButton/ProviderConfig.tsx +5 -4
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/ActionButton/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/RelatedModels/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/provider/{ProviderDetailPage.tsx → index.tsx} +17 -10
- package/src/app/[variants]/(main)/discover/(detail)/provider/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(list)/(home)/{HomePage.tsx → index.tsx} +14 -0
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +2 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/index.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/Nav.tsx +3 -4
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/index.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/_layout/Desktop.tsx +3 -4
- package/src/app/[variants]/(main)/discover/(list)/assistant/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/Item.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/{AssistantPage.tsx → index.tsx} +18 -4
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(list)/mcp/_layout/Desktop.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/mcp/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/mcp/{McpPage.tsx → index.tsx} +9 -2
- package/src/app/[variants]/(main)/discover/(list)/model/_layout/Desktop.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/model/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/model/{ModelPage.tsx → index.tsx} +9 -2
- package/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/provider/{Client.tsx → index.tsx} +9 -2
- package/src/app/[variants]/(main)/discover/_layout/Desktop/index.tsx +4 -4
- package/src/app/[variants]/(main)/discover/_layout/Mobile/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/components/Title.tsx +1 -1
- package/src/app/[variants]/(main)/discover/features/Search.tsx +2 -2
- package/src/app/[variants]/(main)/discover/features/useNav.tsx +11 -12
- package/src/app/[variants]/(main)/hooks/useActiveTabKey.ts +40 -0
- package/src/app/[variants]/(main)/hooks/usePathname.ts +10 -0
- package/src/app/[variants]/(main)/hooks/useQuery.ts +12 -0
- package/src/app/[variants]/(main)/hooks/useRouter.ts +22 -0
- package/src/app/[variants]/(main)/hooks/useSearchParams.ts +11 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect/index.tsx +5 -5
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicUrlSync.tsx +1 -1
- package/src/app/[variants]/(main)/image/ComingSoon.tsx +15 -0
- package/src/app/[variants]/(main)/image/_layout/Desktop/index.tsx +5 -2
- package/src/app/[variants]/(main)/image/_layout/DesktopWrapper.tsx +15 -0
- package/src/app/[variants]/(main)/image/_layout/Mobile/index.tsx +3 -1
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/index.tsx +1 -2
- package/src/app/[variants]/(main)/image/index.tsx +18 -0
- package/src/app/[variants]/(main)/knowledge/_layout/Desktop.tsx +17 -0
- package/src/app/[variants]/(main)/knowledge/_layout/Mobile.tsx +17 -0
- package/src/app/[variants]/(main)/knowledge/components/KnowledgeBaseItem/index.tsx +1 -1
- package/src/app/[variants]/(main)/knowledge/components/modal/ModalPageClient.tsx +4 -4
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/index.tsx +5 -8
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/menu/Head.tsx +1 -1
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/menu/CategoryMenu.tsx +2 -2
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/menu/KnowledgeBase.tsx +1 -1
- package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/DesktopLayoutContainer.tsx +3 -2
- package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/BottomActions.tsx +4 -4
- package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/TopActions.test.tsx +9 -9
- package/src/app/[variants]/(main)/layouts/desktop/SideBar/TopActions.tsx +117 -0
- package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/index.tsx +9 -4
- package/src/app/[variants]/(main)/layouts/index.tsx +11 -0
- package/src/app/[variants]/(main)/{_layout/Mobile → layouts/mobile}/NavBar.tsx +5 -5
- package/src/app/[variants]/(main)/{_layout/Mobile → layouts/mobile}/index.tsx +10 -7
- package/src/app/[variants]/(main)/profile/(home)/desktop.tsx +26 -0
- package/src/app/[variants]/(main)/profile/(home)/index.tsx +26 -0
- package/src/app/[variants]/(main)/profile/@category/features/CategoryContent.tsx +5 -7
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +3 -2
- package/src/app/[variants]/(main)/profile/_layout/DesktopWrapper.tsx +14 -0
- package/src/app/[variants]/(main)/profile/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/profile/_layout/Mobile/index.tsx +4 -3
- package/src/app/[variants]/(main)/profile/apikey/index.tsx +18 -0
- package/src/app/[variants]/(main)/profile/hooks/useCategory.tsx +6 -6
- package/src/app/[variants]/(main)/profile/security/index.tsx +29 -0
- package/src/app/[variants]/(main)/profile/stats/features/AssistantsRank.tsx +4 -4
- package/src/app/[variants]/(main)/profile/stats/features/TopicsRank.tsx +4 -4
- package/src/app/[variants]/(main)/profile/stats/index.tsx +20 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageTable.tsx +7 -9
- package/src/app/[variants]/(main)/profile/usage/index.tsx +13 -0
- package/src/app/[variants]/(main)/settings/_layout/Desktop/Header.tsx +2 -2
- package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +2 -2
- package/src/app/[variants]/(main)/settings/_layout/DesktopWrapper.tsx +23 -0
- package/src/app/[variants]/(main)/settings/_layout/Mobile/Header.tsx +8 -7
- package/src/app/[variants]/(main)/settings/_layout/Mobile/index.tsx +2 -5
- package/src/app/[variants]/(main)/settings/_layout/MobileWrapper.tsx +23 -0
- package/src/app/[variants]/(main)/settings/agent/AgentMenu/Menu.tsx +2 -4
- package/src/app/[variants]/(main)/settings/agent/index.tsx +2 -4
- package/src/app/[variants]/(main)/settings/provider/(list)/index.tsx +2 -3
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/All.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/Item.tsx +38 -37
- package/src/app/[variants]/(main)/settings/provider/_layout/Mobile.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx +3 -3
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx +3 -3
- package/src/app/[variants]/DesktopRouter.tsx +40 -0
- package/src/app/[variants]/MobileRouter.tsx +41 -0
- package/src/app/[variants]/desktopRouter.config.tsx +364 -0
- package/src/app/[variants]/layout.tsx +1 -3
- package/src/app/[variants]/loaders/routeParams.ts +45 -0
- package/src/app/[variants]/loading/Server/Redirect.tsx +1 -1
- package/src/app/[variants]/mobileRouter.config.tsx +396 -0
- package/src/app/[variants]/page.tsx +17 -6
- package/src/app/desktop/devtools/page.tsx +1 -1
- package/src/app/desktop/layout.tsx +1 -1
- package/src/components/BootErrorBoundary/index.tsx +129 -0
- package/src/components/mdx/constants.ts +1 -0
- package/src/features/ChangelogModal/index.tsx +3 -3
- package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +23 -4
- package/src/features/KnowledgeManager/FileExplorer/index.tsx +4 -4
- package/src/features/KnowledgeManager/Header/FilesSearchBar.tsx +1 -1
- package/src/features/User/UserPanel/PanelContent.tsx +4 -3
- package/src/features/User/UserPanel/useMenu.tsx +20 -14
- package/src/features/User/__tests__/PanelContent.test.tsx +13 -7
- package/src/hooks/useDiscoverTab.ts +2 -2
- package/src/hooks/useInterceptingRoutes.test.ts +23 -26
- package/src/hooks/useInterceptingRoutes.ts +5 -4
- package/src/hooks/usePinnedAgentState.ts +6 -6
- package/src/hooks/useQuery.ts +5 -0
- package/src/hooks/useQueryParam.ts +322 -0
- package/src/hooks/useQueryRoute.test.ts +2 -12
- package/src/hooks/useQueryRoute.ts +5 -5
- package/src/hooks/useShowMobileWorkspace.ts +1 -1
- package/src/hooks/useSwitchSession.ts +4 -3
- package/src/layout/GlobalProvider/ImportSettings.tsx +22 -9
- package/src/layout/GlobalProvider/StoreInitialization.tsx +9 -1
- package/src/locales/default/tool.ts +11 -0
- package/src/proxy.ts +13 -1
- package/src/services/message/index.ts +11 -2
- package/src/store/chat/agents/createAgentExecutors.ts +31 -16
- package/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.ts +218 -0
- package/src/store/chat/slices/aiChat/actions/conversationControl.ts +4 -0
- package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +9 -3
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +142 -61
- package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +5 -6
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +204 -10
- package/src/store/chat/slices/builtinTool/actions/localSystem.ts +45 -182
- package/src/store/chat/slices/builtinTool/actions/search.ts +51 -26
- package/src/store/chat/slices/message/action.test.ts +182 -33
- package/src/store/chat/slices/message/actions/optimisticUpdate.ts +79 -36
- package/src/store/chat/slices/message/actions/query.ts +7 -5
- package/src/store/chat/slices/message/selectors/dbMessage.ts +11 -4
- package/src/store/chat/slices/plugin/action.test.ts +257 -54
- package/src/store/chat/slices/plugin/actions/optimisticUpdate.ts +63 -26
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +52 -19
- package/src/store/chat/slices/plugin/actions/publicApi.ts +6 -1
- package/src/store/chat/slices/plugin/actions/workflow.ts +17 -6
- package/src/store/chat/slices/thread/action.ts +2 -0
- package/src/store/global/action.test.ts +3 -3
- package/src/store/global/actions/workspacePane.ts +2 -1
- package/src/store/global/initialState.ts +10 -2
- package/src/store/user/slices/common/action.ts +4 -0
- package/src/tools/executionRuntimes.ts +3 -0
- package/src/tools/local-system/ExecutionRuntime/index.ts +407 -0
- package/src/tools/local-system/Intervention/EditLocalFile/index.tsx +89 -0
- package/src/tools/local-system/Intervention/WriteFile/index.tsx +72 -0
- package/src/tools/local-system/Intervention/index.ts +4 -0
- package/src/tools/local-system/Render/EditLocalFile/index.tsx +67 -0
- package/src/tools/local-system/Render/ReadLocalFile/ReadFileView.tsx +53 -78
- package/src/tools/local-system/Render/index.ts +2 -0
- package/src/tools/local-system/index.ts +1 -0
- package/src/tools/local-system/type.ts +4 -3
- package/src/app/[variants]/(main)/(mobile)/me/(home)/loading.tsx +0 -38
- package/src/app/[variants]/(main)/(mobile)/me/(home)/page.tsx +0 -40
- package/src/app/[variants]/(main)/(mobile)/me/profile/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/profile/page.tsx +0 -30
- package/src/app/[variants]/(main)/(mobile)/me/settings/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/settings/page.tsx +0 -30
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/TopActions.tsx +0 -106
- package/src/app/[variants]/(main)/changelog/layout.tsx +0 -10
- package/src/app/[variants]/(main)/changelog/modal/page.tsx +0 -23
- package/src/app/[variants]/(main)/changelog/page.tsx +0 -78
- package/src/app/[variants]/(main)/chat/ChatRouter.tsx +0 -83
- package/src/app/[variants]/(main)/chat/_layout/ChatLayout.tsx +0 -22
- package/src/app/[variants]/(main)/chat/components/MainChatPage.tsx +0 -25
- package/src/app/[variants]/(main)/chat/error.tsx +0 -3
- package/src/app/[variants]/(main)/chat/layout.tsx +0 -10
- package/src/app/[variants]/(main)/chat/loading.tsx +0 -3
- package/src/app/[variants]/(main)/chat/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/chat/page.tsx +0 -12
- package/src/app/[variants]/(main)/chat/settings/error.tsx +0 -3
- package/src/app/[variants]/(main)/chat/settings/loading.tsx +0 -3
- package/src/app/[variants]/(main)/chat/settings/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/_layout/DetailLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +0 -51
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/Client.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/Client.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/Client.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(list)/_layout/ListLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/mcp/Client.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/mcp/McpLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/model/Client.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/model/ModelLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/provider/ProviderPage.tsx +0 -43
- package/src/app/[variants]/(main)/discover/DiscoverRouter.tsx +0 -170
- package/src/app/[variants]/(main)/discover/[[...path]]/page.tsx +0 -12
- package/src/app/[variants]/(main)/discover/_layout/DiscoverLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/error.tsx +0 -3
- package/src/app/[variants]/(main)/discover/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/error.tsx +0 -3
- package/src/app/[variants]/(main)/image/layout.tsx +0 -15
- package/src/app/[variants]/(main)/image/page.tsx +0 -45
- package/src/app/[variants]/(main)/knowledge/KnowledgeRouter.tsx +0 -74
- package/src/app/[variants]/(main)/knowledge/[[...path]]/page.tsx +0 -12
- package/src/app/[variants]/(main)/knowledge/components/modal/page.tsx +0 -13
- package/src/app/[variants]/(main)/knowledge/layout.tsx +0 -12
- package/src/app/[variants]/(main)/layout.tsx +0 -10
- package/src/app/[variants]/(main)/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/profile/apikey/page.tsx +0 -32
- package/src/app/[variants]/(main)/profile/error.tsx +0 -3
- package/src/app/[variants]/(main)/profile/layout.tsx +0 -11
- package/src/app/[variants]/(main)/profile/loading.tsx +0 -3
- package/src/app/[variants]/(main)/profile/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/profile/security/page.tsx +0 -28
- package/src/app/[variants]/(main)/profile/stats/page.tsx +0 -23
- package/src/app/[variants]/(main)/profile/usage/page.tsx +0 -23
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Cover.tsx +0 -48
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Hero.tsx +0 -29
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Post.tsx +0 -57
- package/src/app/[variants]/@modal/(.)changelog/modal/features/PublishedTime.tsx +0 -50
- package/src/app/[variants]/@modal/(.)changelog/modal/features/ReadDetail.tsx +0 -72
- package/src/app/[variants]/@modal/(.)changelog/modal/features/VersionTag.tsx +0 -26
- package/src/app/[variants]/@modal/(.)changelog/modal/layout.tsx +0 -41
- package/src/app/[variants]/@modal/(.)changelog/modal/loading.tsx +0 -10
- package/src/app/[variants]/@modal/(.)changelog/modal/page.tsx +0 -38
- package/src/app/[variants]/@modal/_layout/ModalLayout.tsx +0 -63
- package/src/app/[variants]/@modal/_layout/SettingModalLayout.tsx +0 -71
- package/src/app/[variants]/@modal/default.tsx +0 -3
- package/src/app/[variants]/@modal/error.tsx +0 -3
- package/src/app/[variants]/@modal/layout.tsx +0 -7
- package/src/app/[variants]/@modal/loading.tsx +0 -5
- /package/src/app/[variants]/{@modal/(.)changelog/modal → (main)/changelog}/features/Pagination.tsx +0 -0
- /package/src/app/[variants]/{@modal/(.)changelog/modal → (main)/changelog}/features/UpdateChangelogStatus.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/Knowledge.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/KnowledgeItem.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/PluginItem.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/Plugins.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Overview/TagList.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/SystemRole/TagList.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/Summary/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/loading.tsx → loading.tsx} +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/ActionButton/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/ConnectionTypeAlert.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Overview/ProviderList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Parameter/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/RelatedProviders/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Guide/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Overview/ModelList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Overview/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Header.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/RelatedModels/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/labs/{page.tsx → index.tsx} +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/RegisterHotkeys.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/Avatar.test.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/Avatar.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/PinList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/index.tsx +0 -0
|
@@ -2,9 +2,9 @@ import { ProviderIcon } from '@lobehub/icons';
|
|
|
2
2
|
import { Avatar } from '@lobehub/ui';
|
|
3
3
|
import { Badge } from 'antd';
|
|
4
4
|
import { createStyles } from 'antd-style';
|
|
5
|
-
import { useSearchParams } from 'next/navigation';
|
|
6
5
|
import { memo } from 'react';
|
|
7
6
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
7
|
+
import { useSearchParams } from 'react-router-dom';
|
|
8
8
|
|
|
9
9
|
import { AiProviderListItem, AiProviderSourceEnum } from '@/types/aiProvider';
|
|
10
10
|
|
|
@@ -42,43 +42,44 @@ interface ProviderItemProps extends AiProviderListItem {
|
|
|
42
42
|
const ProviderItem = memo<ProviderItemProps>(
|
|
43
43
|
({ id, name, source, enabled, logo, onClick = () => {} }) => {
|
|
44
44
|
const { styles, cx } = useStyles();
|
|
45
|
-
const searchParams = useSearchParams();
|
|
45
|
+
const [searchParams] = useSearchParams();
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const activeKey = searchParams.get('provider');
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
const isCustom = source === AiProviderSourceEnum.Custom;
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
className={cx(styles.container, activeKey === id && styles.active)}
|
|
53
|
+
onClick={() => {
|
|
54
|
+
onClick(id);
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Flexbox gap={8} horizontal>
|
|
58
|
+
{isCustom && logo ? (
|
|
59
|
+
<Avatar
|
|
60
|
+
alt={name || id}
|
|
61
|
+
avatar={logo}
|
|
62
|
+
shape={'square'}
|
|
63
|
+
size={24}
|
|
64
|
+
style={{ borderRadius: 6 }}
|
|
65
|
+
/>
|
|
66
|
+
) : (
|
|
67
|
+
<ProviderIcon provider={id} size={24} style={{ borderRadius: 6 }} type={'avatar'} />
|
|
68
|
+
)}
|
|
69
|
+
{name}
|
|
70
|
+
</Flexbox>
|
|
71
|
+
<Flexbox horizontal>
|
|
72
|
+
{enabled && (
|
|
73
|
+
<Center width={24}>
|
|
74
|
+
<Badge status="success" />
|
|
75
|
+
</Center>
|
|
76
|
+
)}
|
|
77
|
+
{/* cloud slot */}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
79
|
+
{/* cloud slot */}
|
|
80
|
+
</Flexbox>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
);
|
|
84
85
|
export default ProviderItem;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useSearchParams } from 'next/navigation';
|
|
4
3
|
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { useSearchParams } from 'react-router-dom';
|
|
5
5
|
|
|
6
6
|
import ProviderMenu from '../ProviderMenu';
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ interface LayoutProps extends PropsWithChildren {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const Layout = ({ children, onProviderSelect }: LayoutProps) => {
|
|
13
|
-
const searchParams = useSearchParams();
|
|
13
|
+
const [searchParams] = useSearchParams();
|
|
14
14
|
const provider = searchParams.get('provider');
|
|
15
15
|
return provider === 'all' || !provider ? (
|
|
16
16
|
<ProviderMenu mobile={true} onProviderSelect={onProviderSelect} />
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from '@lobehub/ui';
|
|
11
11
|
import { App } from 'antd';
|
|
12
12
|
import { BrainIcon } from 'lucide-react';
|
|
13
|
-
import { useRouter } from 'next/navigation';
|
|
14
13
|
import { memo, useState } from 'react';
|
|
15
14
|
import { useTranslation } from 'react-i18next';
|
|
16
15
|
import { Flexbox } from 'react-layout-kit';
|
|
16
|
+
import { useNavigate } from 'react-router-dom';
|
|
17
17
|
|
|
18
18
|
import { useAiInfraStore } from '@/store/aiInfra/store';
|
|
19
19
|
import { CreateAiProviderParams } from '@/types/aiProvider';
|
|
@@ -31,7 +31,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open }) => {
|
|
|
31
31
|
const [loading, setLoading] = useState(false);
|
|
32
32
|
const createNewAiProvider = useAiInfraStore((s) => s.createNewAiProvider);
|
|
33
33
|
const { message } = App.useApp();
|
|
34
|
-
const
|
|
34
|
+
const navigate = useNavigate();
|
|
35
35
|
const onFinish = async (values: CreateAiProviderParams) => {
|
|
36
36
|
setLoading(true);
|
|
37
37
|
|
|
@@ -44,7 +44,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open }) => {
|
|
|
44
44
|
|
|
45
45
|
await createNewAiProvider(finalValues);
|
|
46
46
|
setLoading(false);
|
|
47
|
-
|
|
47
|
+
navigate(`/settings?active=provider&provider=${values.id}`);
|
|
48
48
|
message.success(t('createNewAiProvider.createSuccess'));
|
|
49
49
|
onClose?.();
|
|
50
50
|
} catch (e) {
|
|
@@ -2,10 +2,10 @@ import { ProviderIcon } from '@lobehub/icons';
|
|
|
2
2
|
import { Button, type FormItemProps, FormModal, Icon, Input, Select, TextArea } from '@lobehub/ui';
|
|
3
3
|
import { App } from 'antd';
|
|
4
4
|
import { BrainIcon } from 'lucide-react';
|
|
5
|
-
import { useRouter } from 'next/navigation';
|
|
6
5
|
import { memo, useState } from 'react';
|
|
7
6
|
import { useTranslation } from 'react-i18next';
|
|
8
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
|
+
import { useNavigate } from 'react-router-dom';
|
|
9
9
|
|
|
10
10
|
import { useAiInfraStore } from '@/store/aiInfra/store';
|
|
11
11
|
import { AiProviderDetailItem, UpdateAiProviderParams } from '@/types/aiProvider';
|
|
@@ -28,7 +28,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initial
|
|
|
28
28
|
]);
|
|
29
29
|
|
|
30
30
|
const { message, modal } = App.useApp();
|
|
31
|
-
const
|
|
31
|
+
const navigate = useNavigate();
|
|
32
32
|
|
|
33
33
|
const onFinish = async (values: UpdateAiProviderParams) => {
|
|
34
34
|
setLoading(true);
|
|
@@ -117,7 +117,7 @@ const CreateNewProvider = memo<CreateNewProviderProps>(({ onClose, open, initial
|
|
|
117
117
|
okText: t('delete', { ns: 'common' }),
|
|
118
118
|
onOk: async () => {
|
|
119
119
|
await deleteAiProvider(id);
|
|
120
|
-
|
|
120
|
+
navigate('/settings?active=provider');
|
|
121
121
|
|
|
122
122
|
onClose?.();
|
|
123
123
|
message.success(t('updateAiProvider.deleteSuccess'));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import dynamic from 'next/dynamic';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
|
+
import { RouterProvider } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
import BootErrorBoundary from '@/components/BootErrorBoundary';
|
|
8
|
+
import Loading from '@/components/Loading/BrandTextLoading';
|
|
9
|
+
import type { Locales } from '@/types/locale';
|
|
10
|
+
|
|
11
|
+
import { createDesktopRouter } from './desktopRouter.config';
|
|
12
|
+
|
|
13
|
+
interface ClientRouterProps {
|
|
14
|
+
locale: Locales;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ClientRouter = memo<ClientRouterProps>(({ locale }) => {
|
|
18
|
+
const router = useMemo(() => createDesktopRouter(locale), [locale]);
|
|
19
|
+
return (
|
|
20
|
+
<BootErrorBoundary fallback={<Loading />}>
|
|
21
|
+
<RouterProvider router={router} />
|
|
22
|
+
</BootErrorBoundary>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
ClientRouter.displayName = 'ClientRouter';
|
|
27
|
+
|
|
28
|
+
const DesktopRouterClient = dynamic(() => Promise.resolve(ClientRouter), {
|
|
29
|
+
loading: () => <Loading />,
|
|
30
|
+
ssr: false,
|
|
31
|
+
});
|
|
32
|
+
interface DesktopRouterProps {
|
|
33
|
+
locale: Locales;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const DesktopRouter = ({ locale }: DesktopRouterProps) => {
|
|
37
|
+
return <DesktopRouterClient locale={locale} />;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default DesktopRouter;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import dynamic from 'next/dynamic';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
|
+
import { RouterProvider } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
import BootErrorBoundary from '@/components/BootErrorBoundary';
|
|
8
|
+
import Loading from '@/components/Loading/BrandTextLoading';
|
|
9
|
+
import type { Locales } from '@/types/locale';
|
|
10
|
+
|
|
11
|
+
import { createMobileRouter } from './mobileRouter.config';
|
|
12
|
+
|
|
13
|
+
interface ClientRouterProps {
|
|
14
|
+
locale: Locales;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ClientRouter = memo<ClientRouterProps>(({ locale }) => {
|
|
18
|
+
const router = useMemo(() => createMobileRouter(locale), [locale]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<BootErrorBoundary fallback={<Loading />}>
|
|
22
|
+
<RouterProvider router={router} />
|
|
23
|
+
</BootErrorBoundary>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
ClientRouter.displayName = 'ClientRouter';
|
|
28
|
+
|
|
29
|
+
const MobileRouterClient = dynamic(() => Promise.resolve(ClientRouter), {
|
|
30
|
+
loading: () => <Loading />,
|
|
31
|
+
ssr: false,
|
|
32
|
+
});
|
|
33
|
+
interface MobileRouterProps {
|
|
34
|
+
locale: Locales;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MobileRouter = ({ locale }: MobileRouterProps) => {
|
|
38
|
+
return <MobileRouterClient locale={locale} />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default MobileRouter;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { type LoaderFunction, createBrowserRouter, redirect, useNavigate } from 'react-router-dom';
|
|
5
|
+
|
|
6
|
+
import Loading from '@/components/Loading/BrandTextLoading';
|
|
7
|
+
import { useGlobalStore } from '@/store/global';
|
|
8
|
+
import type { Locales } from '@/types/locale';
|
|
9
|
+
|
|
10
|
+
import DesktopMainLayout from './(main)/layouts/desktop';
|
|
11
|
+
import { idLoader, slugLoader } from './loaders/routeParams';
|
|
12
|
+
|
|
13
|
+
// Component to register navigate function in global store
|
|
14
|
+
const NavigatorRegistrar = () => {
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
useGlobalStore.setState({ navigate });
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
useGlobalStore.setState({ navigate: undefined });
|
|
22
|
+
};
|
|
23
|
+
}, [navigate]);
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Root layout wrapper component - just registers navigator and renders outlet
|
|
29
|
+
// Note: Desktop layout is provided by individual route components
|
|
30
|
+
const RootLayout = (props: { locale: Locales }) => {
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<NavigatorRegistrar />
|
|
34
|
+
<DesktopMainLayout locale={props.locale} />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Hydration gate loader - waits for client state to be ready before rendering
|
|
40
|
+
const hydrationGateLoader: LoaderFunction = () => {
|
|
41
|
+
const { isAppHydrated } = useGlobalStore.getState();
|
|
42
|
+
|
|
43
|
+
// 如果状态已经就绪,直接放行
|
|
44
|
+
if (isAppHydrated) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 否则,返回一个 Promise,"暂停" 渲染
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
console.log('[HydrationGate] Waiting for client state...');
|
|
51
|
+
// 订阅 useGlobalStore 的变化
|
|
52
|
+
const unsubscribe = useGlobalStore.subscribe((state) => {
|
|
53
|
+
if (state.isAppHydrated) {
|
|
54
|
+
console.log('[HydrationGate] Client state ready. Gate opened!');
|
|
55
|
+
unsubscribe(); // 清理订阅
|
|
56
|
+
resolve(null); // Promise 完成,门卫放行
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Create desktop router configuration
|
|
63
|
+
export const createDesktopRouter = (locale: Locales) =>
|
|
64
|
+
createBrowserRouter([
|
|
65
|
+
{
|
|
66
|
+
HydrateFallback: () => <Loading />,
|
|
67
|
+
children: [
|
|
68
|
+
// Chat routes
|
|
69
|
+
{
|
|
70
|
+
children: [
|
|
71
|
+
{
|
|
72
|
+
index: true,
|
|
73
|
+
lazy: () =>
|
|
74
|
+
import('./(main)/chat/index').then((m) => ({
|
|
75
|
+
Component: m.DesktopChatPage,
|
|
76
|
+
})),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
lazy: () =>
|
|
80
|
+
import('./(main)/chat/index').then((m) => ({
|
|
81
|
+
Component: m.DesktopChatPage,
|
|
82
|
+
})),
|
|
83
|
+
path: '*',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
lazy: () =>
|
|
87
|
+
import('./(main)/chat/_layout/Desktop').then((m) => ({
|
|
88
|
+
Component: m.default,
|
|
89
|
+
})),
|
|
90
|
+
path: 'chat',
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// Discover routes with nested structure
|
|
94
|
+
{
|
|
95
|
+
children: [
|
|
96
|
+
// List routes (with ListLayout)
|
|
97
|
+
{
|
|
98
|
+
children: [
|
|
99
|
+
{
|
|
100
|
+
children: [
|
|
101
|
+
{
|
|
102
|
+
index: true,
|
|
103
|
+
lazy: () =>
|
|
104
|
+
import('./(main)/discover/(list)/assistant/index').then((m) => ({
|
|
105
|
+
Component: m.DesktopAssistantPage,
|
|
106
|
+
})),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
lazy: () =>
|
|
110
|
+
import('./(main)/discover/(list)/assistant/_layout/Desktop').then((m) => ({
|
|
111
|
+
Component: m.default,
|
|
112
|
+
})),
|
|
113
|
+
path: 'assistant',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
children: [
|
|
117
|
+
{
|
|
118
|
+
index: true,
|
|
119
|
+
lazy: () =>
|
|
120
|
+
import('./(main)/discover/(list)/model/index').then((m) => ({
|
|
121
|
+
Component: m.DesktopModelPage,
|
|
122
|
+
})),
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
lazy: () =>
|
|
126
|
+
import('./(main)/discover/(list)/model/_layout/Desktop').then((m) => ({
|
|
127
|
+
Component: m.default,
|
|
128
|
+
})),
|
|
129
|
+
path: 'model',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
lazy: () =>
|
|
133
|
+
import('./(main)/discover/(list)/provider/index').then((m) => ({
|
|
134
|
+
Component: m.DesktopProviderPage,
|
|
135
|
+
})),
|
|
136
|
+
path: 'provider',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
children: [
|
|
140
|
+
{
|
|
141
|
+
index: true,
|
|
142
|
+
lazy: () =>
|
|
143
|
+
import('./(main)/discover/(list)/mcp/index').then((m) => ({
|
|
144
|
+
Component: m.DesktopMcpPage,
|
|
145
|
+
})),
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
lazy: () =>
|
|
149
|
+
import('./(main)/discover/(list)/mcp/_layout/Desktop').then((m) => ({
|
|
150
|
+
Component: m.default,
|
|
151
|
+
})),
|
|
152
|
+
path: 'mcp',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
index: true,
|
|
156
|
+
lazy: () =>
|
|
157
|
+
import('./(main)/discover/(list)/(home)/index').then((m) => ({
|
|
158
|
+
Component: m.DesktopHomePage,
|
|
159
|
+
})),
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
lazy: () =>
|
|
163
|
+
import('./(main)/discover/(list)/_layout/Desktop/index').then((m) => ({
|
|
164
|
+
Component: m.default,
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
167
|
+
// Detail routes (with DetailLayout)
|
|
168
|
+
{
|
|
169
|
+
children: [
|
|
170
|
+
{
|
|
171
|
+
lazy: () =>
|
|
172
|
+
import('./(main)/discover/(detail)/assistant/index').then((m) => ({
|
|
173
|
+
Component: m.DesktopDiscoverAssistantDetailPage,
|
|
174
|
+
})),
|
|
175
|
+
loader: slugLoader,
|
|
176
|
+
path: 'assistant/:slug',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
lazy: () =>
|
|
180
|
+
import('./(main)/discover/(detail)/model/index').then((m) => ({
|
|
181
|
+
Component: m.DesktopModelPage,
|
|
182
|
+
})),
|
|
183
|
+
loader: slugLoader,
|
|
184
|
+
path: 'model/:slug',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
lazy: () =>
|
|
188
|
+
import('./(main)/discover/(detail)/provider/index').then((m) => ({
|
|
189
|
+
Component: m.DesktopProviderPage,
|
|
190
|
+
})),
|
|
191
|
+
loader: slugLoader,
|
|
192
|
+
path: 'provider/:slug',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
lazy: () =>
|
|
196
|
+
import('./(main)/discover/(detail)/mcp/index').then((m) => ({
|
|
197
|
+
Component: m.DesktopMcpPage,
|
|
198
|
+
})),
|
|
199
|
+
loader: slugLoader,
|
|
200
|
+
path: 'mcp/:slug',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
lazy: () =>
|
|
204
|
+
import('./(main)/discover/(detail)/_layout/Desktop').then((m) => ({
|
|
205
|
+
Component: m.default,
|
|
206
|
+
})),
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
lazy: () =>
|
|
210
|
+
import('./(main)/discover/_layout/Desktop/index').then((m) => ({
|
|
211
|
+
Component: m.default,
|
|
212
|
+
})),
|
|
213
|
+
path: 'discover',
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
// Knowledge routes
|
|
217
|
+
{
|
|
218
|
+
children: [
|
|
219
|
+
{
|
|
220
|
+
index: true,
|
|
221
|
+
lazy: () =>
|
|
222
|
+
import('./(main)/knowledge/routes/KnowledgeHome').then((m) => ({
|
|
223
|
+
Component: m.default,
|
|
224
|
+
})),
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
lazy: () =>
|
|
228
|
+
import('./(main)/knowledge/routes/KnowledgeBasesList').then((m) => ({
|
|
229
|
+
Component: m.default,
|
|
230
|
+
})),
|
|
231
|
+
path: 'bases',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
lazy: () =>
|
|
235
|
+
import('./(main)/knowledge/routes/KnowledgeBaseDetail').then((m) => ({
|
|
236
|
+
Component: m.default,
|
|
237
|
+
})),
|
|
238
|
+
loader: idLoader,
|
|
239
|
+
path: 'bases/:id',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
lazy: () =>
|
|
243
|
+
import('./(main)/knowledge/routes/KnowledgeBaseDetail').then((m) => ({
|
|
244
|
+
Component: m.default,
|
|
245
|
+
})),
|
|
246
|
+
loader: idLoader,
|
|
247
|
+
path: '*',
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
lazy: () =>
|
|
251
|
+
import('./(main)/knowledge/_layout/Desktop').then((m) => ({
|
|
252
|
+
Component: m.default,
|
|
253
|
+
})),
|
|
254
|
+
path: 'knowledge',
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// Settings routes
|
|
258
|
+
{
|
|
259
|
+
children: [
|
|
260
|
+
{
|
|
261
|
+
index: true,
|
|
262
|
+
lazy: () =>
|
|
263
|
+
import('./(main)/settings/_layout/Desktop').then((m) => ({
|
|
264
|
+
Component: m.default,
|
|
265
|
+
})),
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
lazy: () =>
|
|
269
|
+
import('./(main)/settings/_layout/DesktopWrapper').then((m) => ({
|
|
270
|
+
Component: m.default,
|
|
271
|
+
})),
|
|
272
|
+
path: 'settings',
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
// Image routes
|
|
276
|
+
{
|
|
277
|
+
children: [
|
|
278
|
+
{
|
|
279
|
+
index: true,
|
|
280
|
+
lazy: () =>
|
|
281
|
+
import('./(main)/image').then((m) => ({
|
|
282
|
+
Component: m.default,
|
|
283
|
+
})),
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
lazy: () =>
|
|
287
|
+
import('./(main)/image/_layout/DesktopWrapper').then((m) => ({
|
|
288
|
+
Component: m.default,
|
|
289
|
+
})),
|
|
290
|
+
path: 'image',
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
// Labs routes
|
|
294
|
+
{
|
|
295
|
+
lazy: () =>
|
|
296
|
+
import('./(main)/labs').then((m) => ({
|
|
297
|
+
Component: m.default,
|
|
298
|
+
})),
|
|
299
|
+
path: 'labs',
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
// Profile routes
|
|
303
|
+
{
|
|
304
|
+
children: [
|
|
305
|
+
{
|
|
306
|
+
index: true,
|
|
307
|
+
lazy: () =>
|
|
308
|
+
import('./(main)/profile/(home)/desktop').then((m) => ({
|
|
309
|
+
Component: m.default,
|
|
310
|
+
})),
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
lazy: () =>
|
|
314
|
+
import('./(main)/profile/apikey/index').then((m) => ({
|
|
315
|
+
Component: m.default,
|
|
316
|
+
})),
|
|
317
|
+
path: 'apikey',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
lazy: () =>
|
|
321
|
+
import('./(main)/profile/security/index').then((m) => ({
|
|
322
|
+
Component: m.DesktopProfileSecurityPage,
|
|
323
|
+
})),
|
|
324
|
+
path: 'security',
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
lazy: () =>
|
|
328
|
+
import('./(main)/profile/stats/index').then((m) => ({
|
|
329
|
+
Component: m.DesktopProfileStatsPage,
|
|
330
|
+
})),
|
|
331
|
+
path: 'stats',
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
lazy: () =>
|
|
335
|
+
import('./(main)/profile/usage/index').then((m) => ({
|
|
336
|
+
Component: m.DesktopProfileUsagePage,
|
|
337
|
+
})),
|
|
338
|
+
path: 'usage',
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
lazy: () =>
|
|
342
|
+
import('./(main)/profile/_layout/DesktopWrapper').then((m) => ({
|
|
343
|
+
Component: m.default,
|
|
344
|
+
})),
|
|
345
|
+
path: 'profile',
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
// Default route - redirect to chat
|
|
349
|
+
{
|
|
350
|
+
index: true,
|
|
351
|
+
loader: () => redirect('/chat', { status: 302 }),
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
// Catch-all route
|
|
355
|
+
{
|
|
356
|
+
loader: () => redirect('/chat', { status: 302 }),
|
|
357
|
+
path: '*',
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
element: <RootLayout locale={locale} />,
|
|
361
|
+
loader: hydrationGateLoader,
|
|
362
|
+
path: '/',
|
|
363
|
+
},
|
|
364
|
+
]);
|
|
@@ -19,10 +19,9 @@ const inVercel = process.env.VERCEL === '1';
|
|
|
19
19
|
|
|
20
20
|
interface RootLayoutProps extends DynamicLayoutProps {
|
|
21
21
|
children: ReactNode;
|
|
22
|
-
modal: ReactNode;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
const RootLayout = async ({ children, params
|
|
24
|
+
const RootLayout = async ({ children, params }: RootLayoutProps) => {
|
|
26
25
|
const { variants } = await params;
|
|
27
26
|
|
|
28
27
|
const { locale, isMobile, theme, primaryColor, neutralColor } =
|
|
@@ -50,7 +49,6 @@ const RootLayout = async ({ children, params, modal }: RootLayoutProps) => {
|
|
|
50
49
|
>
|
|
51
50
|
<AuthProvider>
|
|
52
51
|
{children}
|
|
53
|
-
{!isMobile && modal}
|
|
54
52
|
</AuthProvider>
|
|
55
53
|
<PWAInstall />
|
|
56
54
|
</GlobalProvider>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LoaderFunctionArgs } from 'react-router-dom';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic route params loader
|
|
5
|
+
* Extracts all params from the route and returns them
|
|
6
|
+
* Usage: loader: routeParamsLoader
|
|
7
|
+
* Access in component: const params = useLoaderData<RouteParams>();
|
|
8
|
+
*/
|
|
9
|
+
export interface RouteParams {
|
|
10
|
+
[key: string]: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const routeParamsLoader = ({ params }: LoaderFunctionArgs): RouteParams => {
|
|
14
|
+
return params;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Specific loader for routes with 'slug' param
|
|
19
|
+
* Returns: { slug: string }
|
|
20
|
+
*/
|
|
21
|
+
export interface SlugParams {
|
|
22
|
+
slug: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const slugLoader = ({ params }: LoaderFunctionArgs): SlugParams => {
|
|
26
|
+
if (!params.slug) {
|
|
27
|
+
throw new Error('Slug parameter is required');
|
|
28
|
+
}
|
|
29
|
+
return { slug: params.slug };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Specific loader for routes with 'id' param
|
|
34
|
+
* Returns: { id: string }
|
|
35
|
+
*/
|
|
36
|
+
export interface IdParams {
|
|
37
|
+
id: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const idLoader = ({ params }: LoaderFunctionArgs): IdParams => {
|
|
41
|
+
if (!params.id) {
|
|
42
|
+
throw new Error('ID parameter is required');
|
|
43
|
+
}
|
|
44
|
+
return { id: params.id };
|
|
45
|
+
};
|