@lobehub/chat 1.17.6 → 1.18.0
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.
Potentially problematic release.
This version of @lobehub/chat might be problematic. Click here for more details.
- package/CHANGELOG.md +58 -0
- package/locales/ar/common.json +1 -1
- package/locales/ar/discover.json +204 -0
- package/locales/ar/metadata.json +20 -3
- package/locales/ar/models.json +845 -0
- package/locales/ar/providers.json +80 -0
- package/locales/bg-BG/common.json +1 -1
- package/locales/bg-BG/discover.json +204 -0
- package/locales/bg-BG/metadata.json +20 -3
- package/locales/bg-BG/models.json +845 -0
- package/locales/bg-BG/providers.json +80 -0
- package/locales/de-DE/common.json +1 -1
- package/locales/de-DE/discover.json +204 -0
- package/locales/de-DE/metadata.json +20 -3
- package/locales/de-DE/models.json +845 -0
- package/locales/de-DE/providers.json +80 -0
- package/locales/en-US/common.json +1 -1
- package/locales/en-US/discover.json +204 -0
- package/locales/en-US/metadata.json +20 -3
- package/locales/en-US/models.json +845 -0
- package/locales/en-US/providers.json +80 -0
- package/locales/es-ES/common.json +1 -1
- package/locales/es-ES/discover.json +204 -0
- package/locales/es-ES/metadata.json +20 -3
- package/locales/es-ES/models.json +845 -0
- package/locales/es-ES/providers.json +80 -0
- package/locales/fr-FR/common.json +1 -1
- package/locales/fr-FR/discover.json +204 -0
- package/locales/fr-FR/metadata.json +20 -3
- package/locales/fr-FR/models.json +845 -0
- package/locales/fr-FR/providers.json +80 -0
- package/locales/it-IT/common.json +1 -1
- package/locales/it-IT/discover.json +204 -0
- package/locales/it-IT/metadata.json +20 -3
- package/locales/it-IT/models.json +845 -0
- package/locales/it-IT/providers.json +80 -0
- package/locales/ja-JP/common.json +1 -1
- package/locales/ja-JP/discover.json +204 -0
- package/locales/ja-JP/metadata.json +20 -3
- package/locales/ja-JP/models.json +845 -0
- package/locales/ja-JP/providers.json +80 -0
- package/locales/ko-KR/common.json +1 -1
- package/locales/ko-KR/discover.json +204 -0
- package/locales/ko-KR/metadata.json +20 -3
- package/locales/ko-KR/models.json +845 -0
- package/locales/ko-KR/providers.json +80 -0
- package/locales/nl-NL/common.json +1 -1
- package/locales/nl-NL/discover.json +204 -0
- package/locales/nl-NL/metadata.json +20 -3
- package/locales/nl-NL/models.json +845 -0
- package/locales/nl-NL/providers.json +80 -0
- package/locales/pl-PL/common.json +1 -1
- package/locales/pl-PL/discover.json +204 -0
- package/locales/pl-PL/metadata.json +20 -3
- package/locales/pl-PL/models.json +845 -0
- package/locales/pl-PL/providers.json +80 -0
- package/locales/pt-BR/common.json +1 -1
- package/locales/pt-BR/discover.json +204 -0
- package/locales/pt-BR/metadata.json +20 -3
- package/locales/pt-BR/models.json +845 -0
- package/locales/pt-BR/providers.json +80 -0
- package/locales/ru-RU/common.json +1 -1
- package/locales/ru-RU/discover.json +204 -0
- package/locales/ru-RU/metadata.json +20 -3
- package/locales/ru-RU/models.json +845 -0
- package/locales/ru-RU/providers.json +80 -0
- package/locales/tr-TR/common.json +1 -1
- package/locales/tr-TR/discover.json +204 -0
- package/locales/tr-TR/metadata.json +20 -3
- package/locales/tr-TR/models.json +845 -0
- package/locales/tr-TR/providers.json +80 -0
- package/locales/vi-VN/common.json +1 -1
- package/locales/vi-VN/discover.json +204 -0
- package/locales/vi-VN/metadata.json +20 -3
- package/locales/vi-VN/models.json +845 -0
- package/locales/vi-VN/providers.json +80 -0
- package/locales/zh-CN/common.json +1 -1
- package/locales/zh-CN/discover.json +204 -0
- package/locales/zh-CN/metadata.json +20 -3
- package/locales/zh-CN/models.json +845 -0
- package/locales/zh-CN/providers.json +80 -0
- package/locales/zh-CN/welcome.json +1 -1
- package/locales/zh-TW/common.json +1 -1
- package/locales/zh-TW/discover.json +204 -0
- package/locales/zh-TW/metadata.json +20 -3
- package/locales/zh-TW/models.json +845 -0
- package/locales/zh-TW/providers.json +80 -0
- package/package.json +3 -2
- package/src/app/(main)/@nav/_layout/Desktop/TopActions.test.tsx +3 -3
- package/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx +3 -3
- package/src/app/(main)/@nav/_layout/Mobile.tsx +3 -3
- package/src/app/(main)/_layout/Mobile.tsx +9 -1
- package/src/app/(main)/discover/(detail)/_layout/Desktop.tsx +24 -0
- package/src/app/(main)/discover/(detail)/_layout/Mobile/Header.tsx +25 -0
- package/src/app/(main)/discover/(detail)/_layout/Mobile/index.tsx +17 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx +35 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/AddAgent.tsx +86 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/TopicList.tsx +74 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/index.tsx +100 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx +118 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/SuggestionItem.tsx +62 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/ToolItem.tsx +19 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/index.tsx +64 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/SystemRole.tsx +35 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Temp.tsx +44 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx +121 -0
- package/src/app/(main)/discover/(detail)/error.tsx +5 -0
- package/src/app/(main)/discover/(detail)/features/Back.tsx +42 -0
- package/src/app/(main)/discover/(detail)/features/Block.tsx +50 -0
- package/src/app/(main)/discover/(detail)/features/DetailLayout.tsx +91 -0
- package/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx +82 -0
- package/src/app/(main)/discover/(detail)/features/ShareButton.tsx +160 -0
- package/src/app/(main)/discover/(detail)/features/SidebarContainer.tsx +19 -0
- package/src/app/(main)/discover/(detail)/layout.tsx +12 -0
- package/src/app/(main)/discover/(detail)/loading.tsx +38 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Actions.tsx +46 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ChatWithModel.tsx +93 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +85 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/SuggestionItem.tsx +75 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ParameterList/ParameterItem.tsx +71 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ParameterList/index.tsx +110 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/ProviderItem.tsx +152 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/index.tsx +45 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx +114 -0
- package/src/app/(main)/discover/(detail)/not-found.tsx +3 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Actions.tsx +35 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx +114 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/SuggestionItem.tsx +62 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InstallPlugin.tsx +87 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/ParameterList.tsx +95 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Schema.tsx +23 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx +103 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/Actions.tsx +49 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/Header.tsx +73 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/SuggestionItem.tsx +75 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/ModelItem.tsx +148 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/index.tsx +60 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ProviderConfig.tsx +80 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/page.tsx +116 -0
- package/src/app/(main)/discover/(list)/(home)/Client.tsx +42 -0
- package/src/app/(main)/discover/(list)/(home)/features/AssistantList.tsx +33 -0
- package/src/app/(main)/discover/(list)/(home)/features/ModelList.tsx +22 -0
- package/src/app/(main)/discover/(list)/(home)/features/PluginList.tsx +25 -0
- package/src/app/(main)/discover/(list)/(home)/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/(home)/page.tsx +54 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/Nav.tsx +118 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/index.tsx +37 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/useScroll.ts +33 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/Header.tsx +62 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/Nav.tsx +94 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/index.tsx +27 -0
- package/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx +64 -0
- package/src/app/(main)/discover/(list)/assistants/_layout/Desktop.tsx +22 -0
- package/src/app/(main)/discover/(list)/assistants/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/assistants/features/Card.tsx +176 -0
- package/src/app/(main)/discover/(list)/assistants/features/Category.tsx +48 -0
- package/src/app/(main)/discover/(list)/assistants/features/List.tsx +97 -0
- package/src/app/(main)/discover/(list)/assistants/features/useCategory.tsx +116 -0
- package/src/app/(main)/discover/(list)/assistants/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/assistants/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/assistants/page.tsx +51 -0
- package/src/app/(main)/discover/(list)/error.tsx +5 -0
- package/src/app/(main)/{market → discover/(list)}/layout.tsx +4 -3
- package/src/app/(main)/discover/(list)/loading.tsx +39 -0
- package/src/app/(main)/discover/(list)/models/[slug]/page.tsx +70 -0
- package/src/app/(main)/discover/(list)/models/_layout/Desktop.tsx +28 -0
- package/src/app/(main)/discover/(list)/models/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/models/features/Card.tsx +116 -0
- package/src/app/(main)/discover/(list)/models/features/Category.tsx +67 -0
- package/src/app/(main)/discover/(list)/models/features/List.tsx +72 -0
- package/src/app/(main)/discover/(list)/models/features/const.ts +9 -0
- package/src/app/(main)/discover/(list)/models/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/models/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/models/page.tsx +61 -0
- package/src/app/(main)/discover/(list)/not-found.tsx +3 -0
- package/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx +64 -0
- package/src/app/(main)/discover/(list)/plugins/_layout/Desktop.tsx +22 -0
- package/src/app/(main)/discover/(list)/plugins/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/plugins/features/Card.tsx +154 -0
- package/src/app/(main)/discover/(list)/plugins/features/Category.tsx +45 -0
- package/src/app/(main)/discover/(list)/plugins/features/List.tsx +96 -0
- package/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx +80 -0
- package/src/app/(main)/discover/(list)/plugins/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/plugins/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/plugins/page.tsx +52 -0
- package/src/app/(main)/discover/(list)/providers/features/Card.tsx +117 -0
- package/src/app/(main)/discover/(list)/providers/features/List.tsx +71 -0
- package/src/app/(main)/discover/(list)/providers/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/providers/page.tsx +52 -0
- package/src/app/(main)/discover/_layout/Desktop/Header.tsx +36 -0
- package/src/app/(main)/discover/_layout/Desktop/index.tsx +21 -0
- package/src/app/(main)/discover/_layout/Mobile/index.tsx +9 -0
- package/src/app/(main)/{market/features/AgentCard/AgentCardBanner.tsx → discover/components/CardBanner.tsx} +5 -5
- package/src/app/(main)/discover/components/CategoryContainer.tsx +18 -0
- package/src/app/(main)/discover/components/CategoryMenu.tsx +39 -0
- package/src/app/(main)/discover/components/GitHubAvatar.tsx +19 -0
- package/src/app/(main)/discover/components/GridLoadingCard.tsx +69 -0
- package/src/app/(main)/discover/components/ListLoading.tsx +66 -0
- package/src/app/(main)/discover/components/Loading.tsx +17 -0
- package/src/app/(main)/discover/components/SearchResultCount.tsx +37 -0
- package/src/app/(main)/discover/components/Statistic.tsx +92 -0
- package/src/app/(main)/discover/components/Title.tsx +76 -0
- package/src/app/(main)/discover/components/VirtuosoGridList/index.tsx +52 -0
- package/src/app/(main)/discover/components/VirtuosoGridList/useScrollParent.ts +19 -0
- package/src/app/(main)/discover/error.tsx +5 -0
- package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/Inner.tsx +9 -10
- package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/index.tsx +9 -9
- package/src/app/(main)/discover/features/LikeButton.tsx +73 -0
- package/src/app/(main)/discover/features/ModelFeatureTags.tsx +77 -0
- package/src/app/(main)/discover/features/StoreSearchBar.tsx +84 -0
- package/src/app/(main)/discover/features/const.ts +2 -0
- package/src/app/(main)/discover/features/useNav.tsx +71 -0
- package/src/app/(main)/discover/layout.tsx +12 -0
- package/src/app/(main)/discover/loading.tsx +9 -0
- package/src/app/(main)/discover/not-found.tsx +3 -0
- package/src/app/(main)/discover/search/_layout/Desktop.tsx +42 -0
- package/src/app/(main)/discover/search/_layout/Mobile/Header.tsx +31 -0
- package/src/app/(main)/discover/search/_layout/Mobile/Nav.tsx +56 -0
- package/src/app/(main)/discover/search/_layout/Mobile/index.tsx +32 -0
- package/src/app/(main)/discover/search/features/AssistantsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/Category.tsx +41 -0
- package/src/app/(main)/discover/search/features/ModelsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/PluginsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/ProvidersResult.tsx +26 -0
- package/src/app/(main)/discover/search/layout.tsx +12 -0
- package/src/app/(main)/discover/search/loading.tsx +1 -0
- package/src/app/(main)/discover/search/page.tsx +78 -0
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +0 -6
- package/src/app/(main)/welcome/features/Actions.tsx +1 -1
- package/src/app/@modal/(.)discover/assistant/[slug]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/layout.tsx +29 -0
- package/src/app/@modal/(.)discover/loading.tsx +3 -0
- package/src/app/@modal/(.)discover/model/[...slugs]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/plugin/[slug]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/provider/[slug]/page.tsx +1 -0
- package/src/app/@modal/features/InterceptingContext.tsx +9 -0
- package/src/app/@modal/layout.tsx +58 -21
- package/src/app/api/{market → assistant}/[id]/route.ts +2 -3
- package/src/app/api/{market → assistant/store}/route.ts +2 -5
- package/src/app/api/plugin/store/route.ts +1 -4
- package/src/app/metadata.ts +3 -0
- package/src/app/redirect/page.tsx +15 -0
- package/src/components/FetchErrorNotification/Description.tsx +2 -0
- package/src/components/InterceptingLink/index.tsx +27 -0
- package/src/components/mdx/CodeBlock.tsx +46 -0
- package/src/components/mdx/Link.tsx +21 -0
- package/src/components/mdx/index.tsx +51 -0
- package/src/config/modelProviders/ollama.ts +0 -8
- package/src/const/discover.ts +63 -1
- package/src/features/Conversation/Error/PluginSettings.tsx +1 -1
- package/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx +1 -1
- package/src/features/Conversation/components/InboxWelcome/AgentsSuggest.tsx +41 -24
- package/src/features/MobileTabBar/index.tsx +3 -3
- package/src/features/PluginDetailModal/APIs.tsx +1 -1
- package/src/features/PluginDevModal/UrlManifestForm.tsx +1 -1
- package/src/features/PluginStore/PluginItem/Action.tsx +1 -1
- package/src/features/PluginsUI/Render/DefaultType/index.tsx +1 -1
- package/src/features/PluginsUI/Render/StandaloneType/index.tsx +1 -1
- package/src/hooks/useInterceptingRoutes.ts +21 -1
- package/src/hooks/useShare.tsx +191 -0
- package/src/libs/agent-runtime/utils/streams/openai.test.ts +43 -0
- package/src/libs/agent-runtime/utils/streams/openai.ts +1 -1
- package/src/locales/create.ts +1 -1
- package/src/locales/default/common.ts +1 -1
- package/src/locales/default/discover.ts +205 -0
- package/src/locales/default/index.ts +6 -2
- package/src/locales/default/metadata.ts +23 -3
- package/src/locales/default/models.ts +15 -0
- package/src/locales/default/providers.ts +15 -0
- package/src/locales/default/welcome.ts +1 -1
- package/src/locales/resources.ts +2 -0
- package/src/server/ld.ts +85 -11
- package/src/server/metadata.ts +41 -3
- package/src/{app/api/market/AgentMarket.test.ts → server/modules/AssistantStore/index.test.ts} +15 -15
- package/src/{app/api/market/AgentMarket.ts → server/modules/AssistantStore/index.ts} +7 -3
- package/src/{app/api/plugin/store/Store.test.ts → server/modules/PluginStore/index.test.ts} +1 -1
- package/src/server/services/discover/index.ts +352 -0
- package/src/server/services/doc/index.tsx +40 -0
- package/src/server/translation.ts +11 -5
- package/src/services/__tests__/__snapshots__/tool.test.ts.snap +1 -1
- package/src/services/{_auth.test.ts → __tests__/_auth.test.ts} +1 -1
- package/src/services/__tests__/assistant.test.ts +82 -0
- package/src/services/__tests__/tool.test.ts +13 -13
- package/src/services/_url.ts +2 -2
- package/src/services/assistant.ts +30 -0
- package/src/services/chat.ts +1 -1
- package/src/services/tool.ts +7 -129
- package/src/store/chat/slices/plugin/action.test.ts +112 -0
- package/src/store/chat/slices/plugin/action.ts +1 -3
- package/src/store/global/initialState.ts +1 -1
- package/src/store/tool/selectors/tool.test.ts +1 -1
- package/src/store/tool/slices/customPlugin/action.test.ts +1 -1
- package/src/store/tool/slices/customPlugin/action.ts +1 -1
- package/src/store/tool/slices/plugin/action.ts +1 -1
- package/src/store/tool/slices/plugin/selectors.test.ts +3 -3
- package/src/store/tool/slices/plugin/selectors.ts +3 -3
- package/src/store/tool/slices/store/action.test.ts +16 -22
- package/src/store/tool/slices/store/action.ts +8 -8
- package/src/types/discover.ts +152 -0
- package/src/types/llm.ts +4 -2
- package/src/types/meta.ts +1 -0
- package/src/utils/format.test.ts +191 -112
- package/src/utils/format.ts +36 -0
- package/src/utils/toolManifest.ts +124 -0
- package/src/app/(main)/market/@detail/default.tsx +0 -12
- package/src/app/(main)/market/@detail/features/AgentDetailContent.tsx +0 -73
- package/src/app/(main)/market/@detail/features/Banner.tsx +0 -46
- package/src/app/(main)/market/@detail/features/Comment.tsx +0 -16
- package/src/app/(main)/market/@detail/features/Header.tsx +0 -81
- package/src/app/(main)/market/@detail/features/Loading.tsx +0 -63
- package/src/app/(main)/market/@detail/features/TokenTag.tsx +0 -27
- package/src/app/(main)/market/@detail/features/style.ts +0 -32
- package/src/app/(main)/market/_layout/Desktop/DetailSidebar.tsx +0 -84
- package/src/app/(main)/market/_layout/Desktop/Header.tsx +0 -29
- package/src/app/(main)/market/_layout/Desktop/Hero.tsx +0 -40
- package/src/app/(main)/market/_layout/Desktop/index.tsx +0 -46
- package/src/app/(main)/market/_layout/Mobile/DetailModal.tsx +0 -32
- package/src/app/(main)/market/_layout/Mobile/Header.tsx +0 -20
- package/src/app/(main)/market/_layout/Mobile/index.tsx +0 -25
- package/src/app/(main)/market/_layout/type.ts +0 -6
- package/src/app/(main)/market/features/AgentCard/index.tsx +0 -139
- package/src/app/(main)/market/features/AgentList.tsx +0 -103
- package/src/app/(main)/market/features/AgentSearchBar.tsx +0 -42
- package/src/app/(main)/market/features/TagList.tsx +0 -69
- package/src/app/(main)/market/loading.tsx +0 -15
- package/src/app/(main)/market/page.tsx +0 -44
- package/src/const/market.ts +0 -15
- package/src/locales/default/market.ts +0 -32
- package/src/services/market.ts +0 -22
- package/src/store/market/action.ts +0 -82
- package/src/store/market/index.ts +0 -3
- package/src/store/market/initialState.ts +0 -19
- package/src/store/market/selectors.ts +0 -38
- package/src/store/market/store.ts +0 -48
- package/src/types/market.ts +0 -20
- /package/src/{app/api/plugin/store/Store.ts → server/modules/PluginStore/index.ts} +0 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
import { Icon, Tooltip } from '@lobehub/ui';
|
2
|
+
import { Typography } from 'antd';
|
3
|
+
import { createStyles } from 'antd-style';
|
4
|
+
import { HelpCircleIcon } from 'lucide-react';
|
5
|
+
import { CSSProperties, ReactNode, memo } from 'react';
|
6
|
+
import { Flexbox, FlexboxProps } from 'react-layout-kit';
|
7
|
+
|
8
|
+
export const useStyles = createStyles(({ css, token }) => ({
|
9
|
+
container: css`
|
10
|
+
overflow: hidden;
|
11
|
+
min-width: 64px;
|
12
|
+
`,
|
13
|
+
number: css`
|
14
|
+
margin: 0 !important;
|
15
|
+
|
16
|
+
font-size: 16px;
|
17
|
+
font-weight: 500;
|
18
|
+
line-height: 1.4;
|
19
|
+
text-align: center;
|
20
|
+
`,
|
21
|
+
title: css`
|
22
|
+
margin: 0 !important;
|
23
|
+
|
24
|
+
font-size: 12px;
|
25
|
+
line-height: 1.2;
|
26
|
+
color: ${token.colorTextSecondary};
|
27
|
+
text-align: center;
|
28
|
+
`,
|
29
|
+
}));
|
30
|
+
|
31
|
+
export interface StatisticProps extends Omit<FlexboxProps, 'children' | 'title'> {
|
32
|
+
title: ReactNode;
|
33
|
+
titleStyle?: CSSProperties;
|
34
|
+
tooltip?: string;
|
35
|
+
value: ReactNode;
|
36
|
+
valuePlacement?: 'top' | 'bottom';
|
37
|
+
valueStyle?: CSSProperties;
|
38
|
+
}
|
39
|
+
|
40
|
+
const Statistic = memo<StatisticProps>(
|
41
|
+
({
|
42
|
+
className,
|
43
|
+
valueStyle,
|
44
|
+
titleStyle,
|
45
|
+
valuePlacement = 'top',
|
46
|
+
tooltip,
|
47
|
+
title,
|
48
|
+
value,
|
49
|
+
...rest
|
50
|
+
}) => {
|
51
|
+
const { cx, styles } = useStyles();
|
52
|
+
const isTop = valuePlacement === 'top';
|
53
|
+
const valueContent = (
|
54
|
+
<Typography.Paragraph className={styles.number} ellipsis={{ rows: 1 }} style={valueStyle}>
|
55
|
+
{value}
|
56
|
+
</Typography.Paragraph>
|
57
|
+
);
|
58
|
+
const titleContent = (
|
59
|
+
<Typography.Paragraph className={styles.title} ellipsis={{ rows: 1 }} style={titleStyle}>
|
60
|
+
{title}
|
61
|
+
{tooltip && <Icon icon={HelpCircleIcon} style={{ marginLeft: '0.4em' }} />}
|
62
|
+
</Typography.Paragraph>
|
63
|
+
);
|
64
|
+
const content = (
|
65
|
+
<Flexbox
|
66
|
+
align={'center'}
|
67
|
+
className={cx(styles.container, className)}
|
68
|
+
flex={1}
|
69
|
+
justify={'center'}
|
70
|
+
{...rest}
|
71
|
+
>
|
72
|
+
{isTop ? (
|
73
|
+
<>
|
74
|
+
{valueContent}
|
75
|
+
{titleContent}
|
76
|
+
</>
|
77
|
+
) : (
|
78
|
+
<>
|
79
|
+
{titleContent}
|
80
|
+
{valueContent}
|
81
|
+
</>
|
82
|
+
)}
|
83
|
+
</Flexbox>
|
84
|
+
);
|
85
|
+
|
86
|
+
if (!tooltip) return content;
|
87
|
+
|
88
|
+
return <Tooltip title={tooltip}>{content}</Tooltip>;
|
89
|
+
},
|
90
|
+
);
|
91
|
+
|
92
|
+
export default Statistic;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { Icon } from '@lobehub/ui';
|
4
|
+
import { Button, Tag } from 'antd';
|
5
|
+
import { createStyles } from 'antd-style';
|
6
|
+
import { ChevronRight } from 'lucide-react';
|
7
|
+
import Link from 'next/link';
|
8
|
+
import { ReactNode, memo } from 'react';
|
9
|
+
import { Flexbox, FlexboxProps } from 'react-layout-kit';
|
10
|
+
|
11
|
+
const useStyles = createStyles(({ css, responsive, token }) => ({
|
12
|
+
more: css`
|
13
|
+
display: flex;
|
14
|
+
align-items: center;
|
15
|
+
color: ${token.colorTextSecondary};
|
16
|
+
`,
|
17
|
+
tag: css`
|
18
|
+
flex: none;
|
19
|
+
|
20
|
+
padding-block: 0.1em;
|
21
|
+
padding-inline: 0.3em;
|
22
|
+
|
23
|
+
font-size: 18px;
|
24
|
+
font-weight: 500;
|
25
|
+
color: ${token.colorTextSecondary};
|
26
|
+
|
27
|
+
background: ${token.colorFillSecondary};
|
28
|
+
border-radius: ${token.borderRadius}px;
|
29
|
+
${responsive.mobile} {
|
30
|
+
font-size: 14px;
|
31
|
+
}
|
32
|
+
`,
|
33
|
+
title: css`
|
34
|
+
margin-block-start: 0.5em;
|
35
|
+
font-size: 24px;
|
36
|
+
font-weight: 600;
|
37
|
+
${responsive.mobile} {
|
38
|
+
font-size: 18px;
|
39
|
+
}
|
40
|
+
`,
|
41
|
+
}));
|
42
|
+
|
43
|
+
interface TitleProps extends FlexboxProps {
|
44
|
+
more?: ReactNode;
|
45
|
+
moreLink?: string;
|
46
|
+
tag?: ReactNode;
|
47
|
+
}
|
48
|
+
|
49
|
+
const Title = memo<TitleProps>(({ tag, children, moreLink, more }) => {
|
50
|
+
const { styles } = useStyles();
|
51
|
+
const title = <h2 className={styles.title}>{children}</h2>;
|
52
|
+
return (
|
53
|
+
<Flexbox align={'center'} gap={16} horizontal justify={'space-between'} width={'100%'}>
|
54
|
+
{tag ? (
|
55
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
56
|
+
{title}
|
57
|
+
<Tag bordered={false} className={styles.tag}>
|
58
|
+
{tag}
|
59
|
+
</Tag>
|
60
|
+
</Flexbox>
|
61
|
+
) : (
|
62
|
+
title
|
63
|
+
)}
|
64
|
+
{moreLink && (
|
65
|
+
<Link href={moreLink} target={moreLink.startsWith('http') ? '_blank' : undefined}>
|
66
|
+
<Button className={styles.more} style={{ paddingInline: 6 }} type={'text'}>
|
67
|
+
<span>{more}</span>
|
68
|
+
<Icon icon={ChevronRight} />
|
69
|
+
</Button>
|
70
|
+
</Link>
|
71
|
+
)}
|
72
|
+
</Flexbox>
|
73
|
+
);
|
74
|
+
});
|
75
|
+
|
76
|
+
export default Title;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { Grid, GridProps } from '@lobehub/ui';
|
2
|
+
import { forwardRef, memo } from 'react';
|
3
|
+
import { Flexbox, FlexboxProps } from 'react-layout-kit';
|
4
|
+
import { VirtuosoGrid, VirtuosoGridProps } from 'react-virtuoso';
|
5
|
+
|
6
|
+
import { useScrollParent } from './useScrollParent';
|
7
|
+
|
8
|
+
const GridList = forwardRef<HTMLDivElement, GridProps>((props, ref) => (
|
9
|
+
<Grid gap={16} maxItemWidth={280} ref={ref} rows={4} {...props} />
|
10
|
+
));
|
11
|
+
|
12
|
+
const List = forwardRef<HTMLDivElement, FlexboxProps>((props, ref) => (
|
13
|
+
<Flexbox gap={16} ref={ref} {...props} />
|
14
|
+
));
|
15
|
+
|
16
|
+
export const VirtuosoList = memo<VirtuosoGridProps<any, any>>(({ data, ...rest }) => {
|
17
|
+
const scrollParent = useScrollParent();
|
18
|
+
const initialItemCount = data && data?.length >= 8 ? 8 : data?.length;
|
19
|
+
return (
|
20
|
+
<VirtuosoGrid
|
21
|
+
components={{ List: List }}
|
22
|
+
customScrollParent={scrollParent}
|
23
|
+
data={data}
|
24
|
+
initialItemCount={initialItemCount}
|
25
|
+
overscan={400}
|
26
|
+
{...rest}
|
27
|
+
/>
|
28
|
+
);
|
29
|
+
});
|
30
|
+
|
31
|
+
const VirtuosoGridList = memo<VirtuosoGridProps<any, any>>(
|
32
|
+
({ data, initialItemCount, ...rest }) => {
|
33
|
+
const scrollParent = useScrollParent();
|
34
|
+
const count = data && data?.length >= 8 ? 8 : data?.length;
|
35
|
+
const maxInitialItemCount =
|
36
|
+
data && data?.length && initialItemCount && initialItemCount > data?.length
|
37
|
+
? data?.length
|
38
|
+
: initialItemCount;
|
39
|
+
return (
|
40
|
+
<VirtuosoGrid
|
41
|
+
components={{ List: GridList }}
|
42
|
+
customScrollParent={scrollParent}
|
43
|
+
data={data}
|
44
|
+
initialItemCount={maxInitialItemCount || count}
|
45
|
+
overscan={400}
|
46
|
+
{...rest}
|
47
|
+
/>
|
48
|
+
);
|
49
|
+
},
|
50
|
+
);
|
51
|
+
|
52
|
+
export default VirtuosoGridList;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
|
3
|
+
import { isOnServerSide } from '@/utils/env';
|
4
|
+
|
5
|
+
import { SCROLL_PARENT_ID } from '../../features/const';
|
6
|
+
|
7
|
+
export const useScrollParent = () => {
|
8
|
+
const [parent, setParent] = useState<HTMLDivElement>();
|
9
|
+
|
10
|
+
useEffect(() => {
|
11
|
+
if (isOnServerSide) return;
|
12
|
+
const scrollParent = document.querySelector(`#${SCROLL_PARENT_ID}`);
|
13
|
+
if (scrollParent) {
|
14
|
+
setParent(scrollParent as HTMLDivElement);
|
15
|
+
}
|
16
|
+
}, []);
|
17
|
+
|
18
|
+
return parent;
|
19
|
+
};
|
package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/Inner.tsx
RENAMED
@@ -5,11 +5,10 @@ import Image from 'next/image';
|
|
5
5
|
import { memo } from 'react';
|
6
6
|
import { useTranslation } from 'react-i18next';
|
7
7
|
|
8
|
-
import { BRANDING_NAME } from '@/const/branding';
|
9
8
|
import { AGENTS_INDEX_GITHUB, imageUrl } from '@/const/url';
|
10
9
|
|
11
10
|
const Inner = memo(() => {
|
12
|
-
const { t } = useTranslation('
|
11
|
+
const { t } = useTranslation('discover');
|
13
12
|
return (
|
14
13
|
<Typography fontSize={14} headerMultiple={0.5} marginMultiple={0.4}>
|
15
14
|
<Image
|
@@ -20,33 +19,33 @@ const Inner = memo(() => {
|
|
20
19
|
width={1602}
|
21
20
|
/>
|
22
21
|
<h3>
|
23
|
-
<Tag color={'cyan'}>{t('
|
24
|
-
<span>{t('
|
22
|
+
<Tag color={'cyan'}>{t('createGuide.func1.tag')}</Tag>
|
23
|
+
<span>{t('createGuide.func1.title')}</span>
|
25
24
|
</h3>
|
26
25
|
<p>
|
27
26
|
<kbd>
|
28
27
|
<Icon icon={Settings} />
|
29
28
|
</kbd>
|
30
|
-
{t('
|
29
|
+
{t('createGuide.func1.desc1')}
|
31
30
|
<br />
|
32
31
|
<kbd>
|
33
32
|
<Icon icon={Share2} />
|
34
33
|
</kbd>
|
35
|
-
{t('
|
34
|
+
{t('createGuide.func1.desc2')}
|
36
35
|
</p>
|
37
36
|
<Divider />
|
38
37
|
<h3>
|
39
|
-
<Tag color={'cyan'}>{t('
|
40
|
-
<span>{t('
|
38
|
+
<Tag color={'cyan'}>{t('createGuide.func2.tag')}</Tag>
|
39
|
+
<span>{t('createGuide.func2.title')}</span>
|
41
40
|
</h3>
|
42
|
-
<p>{t('
|
41
|
+
<p>{t('createGuide.func2.desc')}</p>
|
43
42
|
<br />
|
44
43
|
<Button
|
45
44
|
icon={<Icon icon={Github} />}
|
46
45
|
onClick={() => window.open(AGENTS_INDEX_GITHUB, '__blank')}
|
47
46
|
type={'primary'}
|
48
47
|
>
|
49
|
-
{t('
|
48
|
+
{t('createGuide.func2.button')}
|
50
49
|
</Button>
|
51
50
|
</Typography>
|
52
51
|
);
|
package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/index.tsx
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ActionIcon, Icon, Modal } from '@lobehub/ui';
|
2
2
|
import { Button, Skeleton } from 'antd';
|
3
3
|
import { useResponsive } from 'antd-style';
|
4
|
-
import {
|
4
|
+
import { Brush } from 'lucide-react';
|
5
5
|
import dynamic from 'next/dynamic';
|
6
6
|
import { memo, useState } from 'react';
|
7
7
|
import { useTranslation } from 'react-i18next';
|
@@ -12,22 +12,22 @@ const Inner = dynamic(() => import('./Inner'), {
|
|
12
12
|
loading: () => <Skeleton paragraph={{ rows: 8 }} title={false} />,
|
13
13
|
});
|
14
14
|
|
15
|
-
const
|
15
|
+
const CreateButton = memo<{ mobile?: boolean }>(({ mobile }) => {
|
16
16
|
const { mobile: resMobile } = useResponsive();
|
17
|
-
const { t } = useTranslation('
|
17
|
+
const { t } = useTranslation('discover');
|
18
18
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
19
19
|
|
20
20
|
const buttonContent =
|
21
21
|
mobile || resMobile ? (
|
22
22
|
<ActionIcon
|
23
|
-
icon={
|
23
|
+
icon={Brush}
|
24
24
|
onClick={() => setIsModalOpen(true)}
|
25
25
|
size={MOBILE_HEADER_ICON_SIZE}
|
26
|
-
title={t('
|
26
|
+
title={t('create')}
|
27
27
|
/>
|
28
28
|
) : (
|
29
|
-
<Button icon={<Icon icon={
|
30
|
-
{t('
|
29
|
+
<Button icon={<Icon icon={Brush} />} onClick={() => setIsModalOpen(true)}>
|
30
|
+
{t('create')}
|
31
31
|
</Button>
|
32
32
|
);
|
33
33
|
|
@@ -39,7 +39,7 @@ const ShareAgentButton = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
39
39
|
footer={null}
|
40
40
|
onCancel={() => setIsModalOpen(false)}
|
41
41
|
open={isModalOpen}
|
42
|
-
title={t('
|
42
|
+
title={t('create')}
|
43
43
|
>
|
44
44
|
<Inner />
|
45
45
|
</Modal>
|
@@ -47,4 +47,4 @@ const ShareAgentButton = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
47
47
|
);
|
48
48
|
});
|
49
49
|
|
50
|
-
export default
|
50
|
+
export default CreateButton;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { Icon, Tooltip } from '@lobehub/ui';
|
2
|
+
import { Button, Space } from 'antd';
|
3
|
+
import { ThumbsDownIcon, ThumbsUpIcon } from 'lucide-react';
|
4
|
+
import { memo } from 'react';
|
5
|
+
import { useTranslation } from 'react-i18next';
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
7
|
+
|
8
|
+
import { formatShortenNumber } from '@/utils/format';
|
9
|
+
|
10
|
+
import { useStyles } from '../components/Statistic';
|
11
|
+
|
12
|
+
interface LikeButtonProps {
|
13
|
+
count: number;
|
14
|
+
isDisliked?: boolean;
|
15
|
+
isLiked?: boolean;
|
16
|
+
onDislikeClick?: (active: boolean) => void;
|
17
|
+
onLikeClick?: (active: boolean) => void;
|
18
|
+
showDislike?: boolean;
|
19
|
+
}
|
20
|
+
|
21
|
+
const LikeButton = memo<LikeButtonProps>(
|
22
|
+
({ count, onLikeClick, onDislikeClick, isLiked, showDislike, isDisliked }) => {
|
23
|
+
const { styles } = useStyles();
|
24
|
+
const { t } = useTranslation('discover');
|
25
|
+
|
26
|
+
if (showDislike)
|
27
|
+
return (
|
28
|
+
<Space.Compact style={{ flex: 1.75 }}>
|
29
|
+
<Tooltip title={t('like')}>
|
30
|
+
<Button
|
31
|
+
className={styles.number}
|
32
|
+
icon={<Icon icon={ThumbsUpIcon} />}
|
33
|
+
onClick={() => onLikeClick?.(!isLiked)}
|
34
|
+
size={'large'}
|
35
|
+
style={{ flex: 1 }}
|
36
|
+
type={isLiked ? 'primary' : 'default'}
|
37
|
+
>
|
38
|
+
{formatShortenNumber(count)}
|
39
|
+
</Button>
|
40
|
+
</Tooltip>
|
41
|
+
<Tooltip title={t('dislike')}>
|
42
|
+
<Button
|
43
|
+
className={styles.number}
|
44
|
+
icon={<Icon icon={ThumbsDownIcon} />}
|
45
|
+
onClick={() => onDislikeClick?.(!isDisliked)}
|
46
|
+
size={'large'}
|
47
|
+
style={{ flex: 'none' }}
|
48
|
+
type={isDisliked ? 'primary' : 'default'}
|
49
|
+
/>
|
50
|
+
</Tooltip>
|
51
|
+
</Space.Compact>
|
52
|
+
);
|
53
|
+
|
54
|
+
return (
|
55
|
+
<Flexbox align={'center'} flex={1} justify={'center'} style={{ position: 'relative' }}>
|
56
|
+
<Tooltip title={t('like')}>
|
57
|
+
<Button
|
58
|
+
className={styles.number}
|
59
|
+
icon={<Icon icon={ThumbsUpIcon} />}
|
60
|
+
onClick={() => onLikeClick?.(!isLiked)}
|
61
|
+
size={'large'}
|
62
|
+
style={{ width: '100%' }}
|
63
|
+
type={isLiked ? 'primary' : 'default'}
|
64
|
+
>
|
65
|
+
{formatShortenNumber(count)}
|
66
|
+
</Button>
|
67
|
+
</Tooltip>
|
68
|
+
</Flexbox>
|
69
|
+
);
|
70
|
+
},
|
71
|
+
);
|
72
|
+
|
73
|
+
export default LikeButton;
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { Icon, Tooltip } from '@lobehub/ui';
|
2
|
+
import { Tag } from 'antd';
|
3
|
+
import { createStyles } from 'antd-style';
|
4
|
+
import { LucideEye, ToyBrick } from 'lucide-react';
|
5
|
+
import { memo } from 'react';
|
6
|
+
import { useTranslation } from 'react-i18next';
|
7
|
+
import { Flexbox, FlexboxProps } from 'react-layout-kit';
|
8
|
+
|
9
|
+
import { formatTokenNumber } from '@/utils/format';
|
10
|
+
|
11
|
+
const useStyles = createStyles(({ css, token }) => ({
|
12
|
+
tagBlue: css`
|
13
|
+
color: ${token.geekblue};
|
14
|
+
background: ${token.geekblue1};
|
15
|
+
`,
|
16
|
+
tagGreen: css`
|
17
|
+
color: ${token.green};
|
18
|
+
background: ${token.green1};
|
19
|
+
`,
|
20
|
+
token: css`
|
21
|
+
font-family: ${token.fontFamilyCode};
|
22
|
+
color: ${token.colorTextSecondary};
|
23
|
+
background: ${token.colorFillSecondary};
|
24
|
+
`,
|
25
|
+
}));
|
26
|
+
|
27
|
+
interface TagsProps extends FlexboxProps {
|
28
|
+
functionCall?: boolean;
|
29
|
+
tokens?: number;
|
30
|
+
vision?: boolean;
|
31
|
+
}
|
32
|
+
|
33
|
+
const ModelFeatureTags = memo<TagsProps>(({ children, tokens, vision, functionCall, ...rest }) => {
|
34
|
+
const { t } = useTranslation(['discover', 'components']);
|
35
|
+
const { styles } = useStyles();
|
36
|
+
|
37
|
+
return (
|
38
|
+
<Flexbox align={'center'} gap={4} horizontal wrap={'wrap'} {...rest}>
|
39
|
+
{tokens && (
|
40
|
+
<Tooltip overlayStyle={{ pointerEvents: 'none' }} title={t('models.contentLength')}>
|
41
|
+
<Tag bordered={false} className={styles.token} style={{ flex: 'none', margin: 0 }}>
|
42
|
+
{formatTokenNumber(tokens)}
|
43
|
+
</Tag>
|
44
|
+
</Tooltip>
|
45
|
+
)}
|
46
|
+
{vision && (
|
47
|
+
<Tooltip
|
48
|
+
overlayStyle={{ pointerEvents: 'none' }}
|
49
|
+
title={t('ModelSelect.featureTag.vision', { ns: 'components' })}
|
50
|
+
>
|
51
|
+
<Tag
|
52
|
+
bordered={false}
|
53
|
+
className={styles.tagGreen}
|
54
|
+
icon={<Icon icon={LucideEye} />}
|
55
|
+
style={{ flex: 'none', margin: 0 }}
|
56
|
+
/>
|
57
|
+
</Tooltip>
|
58
|
+
)}
|
59
|
+
{functionCall && (
|
60
|
+
<Tooltip
|
61
|
+
overlayStyle={{ maxWidth: 'unset', pointerEvents: 'none' }}
|
62
|
+
title={t('ModelSelect.featureTag.functionCall', { ns: 'components' })}
|
63
|
+
>
|
64
|
+
<Tag
|
65
|
+
bordered={false}
|
66
|
+
className={styles.tagBlue}
|
67
|
+
icon={<Icon icon={ToyBrick} />}
|
68
|
+
style={{ flex: 'none', margin: 0 }}
|
69
|
+
/>
|
70
|
+
</Tooltip>
|
71
|
+
)}
|
72
|
+
{children}
|
73
|
+
</Flexbox>
|
74
|
+
);
|
75
|
+
});
|
76
|
+
|
77
|
+
export default ModelFeatureTags;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { SearchBar, SearchBarProps } from '@lobehub/ui';
|
4
|
+
import { createStyles } from 'antd-style';
|
5
|
+
import { usePathname } from 'next/navigation';
|
6
|
+
import { useQueryState } from 'nuqs';
|
7
|
+
import { memo, useEffect, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
import urlJoin from 'url-join';
|
10
|
+
|
11
|
+
import { useQuery } from '@/hooks/useQuery';
|
12
|
+
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
13
|
+
import { DiscoverTab } from '@/types/discover';
|
14
|
+
|
15
|
+
import { useNav } from './useNav';
|
16
|
+
|
17
|
+
export const useStyles = createStyles(({ css, prefixCls, token }) => ({
|
18
|
+
active: css`
|
19
|
+
box-shadow: ${token.boxShadow};
|
20
|
+
`,
|
21
|
+
bar: css`
|
22
|
+
.${prefixCls}-input-group-wrapper {
|
23
|
+
padding: 0;
|
24
|
+
}
|
25
|
+
`,
|
26
|
+
}));
|
27
|
+
|
28
|
+
interface StoreSearchBarProps extends SearchBarProps {
|
29
|
+
mobile?: boolean;
|
30
|
+
}
|
31
|
+
|
32
|
+
const StoreSearchBar = memo<StoreSearchBarProps>(({ mobile, onBlur, onFocus, ...rest }) => {
|
33
|
+
const [active, setActive] = useState(false);
|
34
|
+
const pathname = usePathname();
|
35
|
+
const { q } = useQuery();
|
36
|
+
const { activeKey } = useNav();
|
37
|
+
const [searchKey, setSearchKey] = useQueryState('q');
|
38
|
+
|
39
|
+
const { t } = useTranslation('discover');
|
40
|
+
const { cx, styles } = useStyles();
|
41
|
+
const router = useQueryRoute();
|
42
|
+
|
43
|
+
const activeType = activeKey === DiscoverTab.Home ? DiscoverTab.Assistants : activeKey;
|
44
|
+
|
45
|
+
useEffect(() => {
|
46
|
+
if (!pathname.includes('/discover/search')) return;
|
47
|
+
// 使用 useQueryState 时,当 handleSearch 为空时无法回跳
|
48
|
+
if (!q) router.push(urlJoin('/discover', activeType), { query: {}, replace: true });
|
49
|
+
}, [q, pathname, activeType]);
|
50
|
+
|
51
|
+
const handleSearch = (value: string) => {
|
52
|
+
router.push('/discover/search', { query: { q: value, type: activeType } });
|
53
|
+
};
|
54
|
+
|
55
|
+
return (
|
56
|
+
<SearchBar
|
57
|
+
allowClear
|
58
|
+
autoFocus={mobile || active}
|
59
|
+
className={cx(styles.bar, active && styles.active)}
|
60
|
+
defaultValue={searchKey ? String(searchKey) : ''}
|
61
|
+
enableShortKey={!mobile}
|
62
|
+
onBlur={(e) => {
|
63
|
+
setActive(false);
|
64
|
+
onBlur?.(e);
|
65
|
+
}}
|
66
|
+
onChange={(e) => setSearchKey(e.target.value)}
|
67
|
+
onFocus={(e) => {
|
68
|
+
setActive(true);
|
69
|
+
onFocus?.(e);
|
70
|
+
}}
|
71
|
+
onSearch={handleSearch}
|
72
|
+
placeholder={t('search.placeholder')}
|
73
|
+
shortKey={'k'}
|
74
|
+
spotlight={!mobile}
|
75
|
+
style={{ width: mobile || active ? '100%' : 'min(480px,100%)' }}
|
76
|
+
styles={{ input: { width: '100%' } }}
|
77
|
+
type={'block'}
|
78
|
+
value={searchKey ? String(searchKey) : ''}
|
79
|
+
{...rest}
|
80
|
+
/>
|
81
|
+
);
|
82
|
+
});
|
83
|
+
|
84
|
+
export default StoreSearchBar;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
2
|
+
import { Bot, Brain, BrainCircuit, House, Puzzle } from 'lucide-react';
|
3
|
+
import { usePathname } from 'next/navigation';
|
4
|
+
import { ReactNode, useMemo } from 'react';
|
5
|
+
import { useTranslation } from 'react-i18next';
|
6
|
+
import urlJoin from 'url-join';
|
7
|
+
|
8
|
+
import type { MenuProps } from '@/components/Menu';
|
9
|
+
import { useQuery } from '@/hooks/useQuery';
|
10
|
+
import { DiscoverTab } from '@/types/discover';
|
11
|
+
|
12
|
+
export const useNav = () => {
|
13
|
+
const pathname = usePathname();
|
14
|
+
const { type } = useQuery();
|
15
|
+
const { t } = useTranslation('discover');
|
16
|
+
const iconSize = { fontSize: 16 };
|
17
|
+
|
18
|
+
const activeKey = useMemo(() => {
|
19
|
+
for (const value of Object.values(DiscoverTab)) {
|
20
|
+
if (pathname === '/discover/search') {
|
21
|
+
return (type as DiscoverTab) || DiscoverTab.Assistants;
|
22
|
+
} else if (pathname.includes(urlJoin('/discover', value))) {
|
23
|
+
return value;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return DiscoverTab.Home;
|
27
|
+
}, [pathname]);
|
28
|
+
|
29
|
+
const items: MenuProps['items'] = useMemo(
|
30
|
+
() => [
|
31
|
+
{
|
32
|
+
icon: <Icon icon={House} size={iconSize} />,
|
33
|
+
key: DiscoverTab.Home,
|
34
|
+
label: t('tab.home'),
|
35
|
+
},
|
36
|
+
{
|
37
|
+
icon: <Icon icon={Bot} size={iconSize} />,
|
38
|
+
key: DiscoverTab.Assistants,
|
39
|
+
label: t('tab.assistants'),
|
40
|
+
},
|
41
|
+
{
|
42
|
+
icon: <Icon icon={Puzzle} size={iconSize} />,
|
43
|
+
key: DiscoverTab.Plugins,
|
44
|
+
label: t('tab.plugins'),
|
45
|
+
},
|
46
|
+
{
|
47
|
+
icon: <Icon icon={Brain} size={iconSize} />,
|
48
|
+
key: DiscoverTab.Models,
|
49
|
+
label: t('tab.models'),
|
50
|
+
},
|
51
|
+
{
|
52
|
+
icon: <Icon icon={BrainCircuit} size={iconSize} />,
|
53
|
+
key: DiscoverTab.Providers,
|
54
|
+
label: t('tab.providers'),
|
55
|
+
},
|
56
|
+
],
|
57
|
+
[t],
|
58
|
+
);
|
59
|
+
|
60
|
+
const activeItem = items.find((item: any) => item.key === activeKey) as {
|
61
|
+
icon: ReactNode;
|
62
|
+
key: string;
|
63
|
+
label: string;
|
64
|
+
};
|
65
|
+
|
66
|
+
return {
|
67
|
+
activeItem,
|
68
|
+
activeKey,
|
69
|
+
items,
|
70
|
+
};
|
71
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
|
3
|
+
import ServerLayout from '@/components/server/ServerLayout';
|
4
|
+
|
5
|
+
import Desktop from './_layout/Desktop';
|
6
|
+
import Mobile from './_layout/Mobile';
|
7
|
+
|
8
|
+
const MainLayout = ServerLayout<PropsWithChildren>({ Desktop, Mobile });
|
9
|
+
|
10
|
+
MainLayout.displayName = 'DiscoverStoreLayout';
|
11
|
+
|
12
|
+
export default MainLayout;
|