@lobehub/lobehub 2.0.0-next.47 → 2.0.0-next.49
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/.env.example +11 -0
- package/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/apps/desktop/src/main/controllers/AuthCtr.ts +27 -2
- package/apps/desktop/src/main/core/infrastructure/ProtocolManager.ts +9 -4
- package/changelog/v1.json +17 -0
- package/docs/development/database-schema.dbml +2 -0
- package/docs/self-hosting/environment-variables/basic.mdx +49 -3
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +49 -4
- package/locales/ar/chat.json +1 -0
- package/locales/ar/discover.json +45 -0
- package/locales/ar/marketAuth.json +42 -0
- package/locales/ar/setting.json +94 -1
- package/locales/ar/topic.json +1 -0
- package/locales/bg-BG/chat.json +1 -0
- package/locales/bg-BG/discover.json +45 -0
- package/locales/bg-BG/marketAuth.json +42 -0
- package/locales/bg-BG/setting.json +94 -1
- package/locales/bg-BG/topic.json +1 -0
- package/locales/de-DE/chat.json +1 -0
- package/locales/de-DE/discover.json +45 -0
- package/locales/de-DE/marketAuth.json +42 -0
- package/locales/de-DE/setting.json +94 -1
- package/locales/de-DE/topic.json +1 -0
- package/locales/en-US/chat.json +1 -0
- package/locales/en-US/discover.json +45 -0
- package/locales/en-US/marketAuth.json +42 -0
- package/locales/en-US/setting.json +94 -1
- package/locales/en-US/topic.json +1 -0
- package/locales/es-ES/chat.json +1 -0
- package/locales/es-ES/discover.json +45 -0
- package/locales/es-ES/marketAuth.json +42 -0
- package/locales/es-ES/setting.json +94 -1
- package/locales/es-ES/topic.json +1 -0
- package/locales/fa-IR/chat.json +1 -0
- package/locales/fa-IR/discover.json +45 -0
- package/locales/fa-IR/marketAuth.json +42 -0
- package/locales/fa-IR/setting.json +94 -1
- package/locales/fa-IR/topic.json +1 -0
- package/locales/fr-FR/chat.json +1 -0
- package/locales/fr-FR/discover.json +45 -0
- package/locales/fr-FR/marketAuth.json +42 -0
- package/locales/fr-FR/setting.json +94 -1
- package/locales/fr-FR/topic.json +1 -0
- package/locales/it-IT/chat.json +1 -0
- package/locales/it-IT/discover.json +45 -0
- package/locales/it-IT/marketAuth.json +42 -0
- package/locales/it-IT/setting.json +94 -1
- package/locales/it-IT/topic.json +1 -0
- package/locales/ja-JP/chat.json +1 -0
- package/locales/ja-JP/discover.json +45 -0
- package/locales/ja-JP/marketAuth.json +42 -0
- package/locales/ja-JP/setting.json +94 -1
- package/locales/ja-JP/topic.json +1 -0
- package/locales/ko-KR/chat.json +1 -0
- package/locales/ko-KR/discover.json +45 -0
- package/locales/ko-KR/marketAuth.json +42 -0
- package/locales/ko-KR/setting.json +94 -1
- package/locales/ko-KR/topic.json +1 -0
- package/locales/nl-NL/chat.json +1 -0
- package/locales/nl-NL/discover.json +45 -0
- package/locales/nl-NL/marketAuth.json +42 -0
- package/locales/nl-NL/setting.json +94 -1
- package/locales/nl-NL/topic.json +1 -0
- package/locales/pl-PL/chat.json +1 -0
- package/locales/pl-PL/discover.json +45 -0
- package/locales/pl-PL/marketAuth.json +42 -0
- package/locales/pl-PL/setting.json +94 -1
- package/locales/pl-PL/topic.json +1 -0
- package/locales/pt-BR/chat.json +1 -0
- package/locales/pt-BR/discover.json +45 -0
- package/locales/pt-BR/marketAuth.json +42 -0
- package/locales/pt-BR/setting.json +94 -1
- package/locales/pt-BR/topic.json +1 -0
- package/locales/ru-RU/chat.json +1 -0
- package/locales/ru-RU/discover.json +45 -0
- package/locales/ru-RU/marketAuth.json +42 -0
- package/locales/ru-RU/setting.json +94 -1
- package/locales/ru-RU/topic.json +1 -0
- package/locales/tr-TR/chat.json +1 -0
- package/locales/tr-TR/discover.json +45 -0
- package/locales/tr-TR/marketAuth.json +42 -0
- package/locales/tr-TR/setting.json +94 -1
- package/locales/tr-TR/topic.json +1 -0
- package/locales/vi-VN/chat.json +1 -0
- package/locales/vi-VN/discover.json +45 -0
- package/locales/vi-VN/marketAuth.json +42 -0
- package/locales/vi-VN/setting.json +94 -1
- package/locales/vi-VN/topic.json +1 -0
- package/locales/zh-CN/chat.json +1 -0
- package/locales/zh-CN/discover.json +45 -0
- package/locales/zh-CN/marketAuth.json +42 -0
- package/locales/zh-CN/setting.json +94 -1
- package/locales/zh-CN/topic.json +1 -0
- package/locales/zh-TW/chat.json +1 -0
- package/locales/zh-TW/discover.json +45 -0
- package/locales/zh-TW/marketAuth.json +42 -0
- package/locales/zh-TW/setting.json +94 -1
- package/locales/zh-TW/topic.json +1 -0
- package/package.json +34 -27
- package/packages/agent-runtime/src/core/InterventionChecker.ts +5 -16
- package/packages/agent-runtime/src/core/__tests__/InterventionChecker.test.ts +27 -80
- package/packages/agent-runtime/src/core/__tests__/runtime.test.ts +32 -13
- package/packages/agent-runtime/src/core/runtime.ts +7 -3
- package/packages/agent-runtime/src/types/event.ts +2 -1
- package/packages/agent-runtime/src/types/generalAgent.ts +1 -0
- package/packages/agent-runtime/src/types/instruction.ts +3 -2
- package/packages/agent-runtime/src/types/state.ts +3 -1
- package/packages/const/src/url.ts +1 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +4 -1
- package/packages/database/migrations/0044_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/0044_high_toxin.sql +1 -0
- package/packages/database/migrations/0045_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/meta/0039_snapshot.json +1 -1
- package/packages/database/migrations/meta/0044_snapshot.json +7813 -0
- package/packages/database/migrations/meta/0045_snapshot.json +8431 -0
- package/packages/database/migrations/meta/_journal.json +14 -0
- package/packages/database/src/core/migrations.json +36 -7
- package/packages/database/src/models/message.ts +4 -1
- package/packages/database/src/models/session.ts +42 -1
- package/packages/database/src/schemas/agent.ts +1 -0
- package/packages/database/src/schemas/message.ts +5 -8
- package/packages/electron-client-ipc/src/events/index.ts +6 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +8 -0
- package/packages/fetch-sse/package.json +29 -0
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/fetchSSE.test.ts +4 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/parseError.test.ts +7 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/fetchSSE.ts +2 -2
- package/packages/{utils/src/fetch → fetch-sse/src}/parseError.ts +3 -3
- package/packages/model-bank/src/aiModels/mistral.ts +2 -1
- package/packages/model-runtime/src/core/contextBuilders/anthropic.test.ts +17 -11
- package/packages/model-runtime/src/core/contextBuilders/anthropic.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.ts +3 -6
- package/packages/model-runtime/src/core/contextBuilders/openai.test.ts +4 -2
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.test.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts +3 -6
- package/packages/model-runtime/src/core/streams/openai/responsesStream.test.ts +1 -1
- package/packages/model-runtime/src/helpers/mergeChatMethodOptions.ts +2 -1
- package/packages/model-runtime/src/providers/aihubmix/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/baichuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bedrock/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/providers/bfl/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/cloudflare/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/cohere/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/createImage.test.ts +2 -2
- package/packages/model-runtime/src/providers/google/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/google/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/index.test.ts +1 -4
- package/packages/model-runtime/src/providers/groq/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/hunyuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/minimax/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/mistral/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/moonshot/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/novita/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ollama/index.test.ts +43 -32
- package/packages/model-runtime/src/providers/ollama/index.ts +31 -7
- package/packages/model-runtime/src/providers/openrouter/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/perplexity/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ppio/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/qwen/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/search1api/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/siliconcloud/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/taichu/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/wenxin/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/zhipu/index.test.ts +1 -1
- package/packages/model-runtime/src/utils/errorResponse.test.ts +1 -1
- package/packages/obervability-otel/src/node.ts +15 -1
- package/packages/ssrf-safe-fetch/index.browser.ts +14 -0
- package/packages/ssrf-safe-fetch/package.json +8 -1
- package/packages/types/src/discover/assistants.ts +16 -0
- package/packages/types/src/index.ts +1 -0
- package/packages/types/src/message/common/base.ts +2 -2
- package/packages/types/src/message/common/tools.ts +16 -0
- package/packages/types/src/message/db/item.ts +15 -1
- package/packages/types/src/message/ui/chat.ts +7 -1
- package/packages/types/src/message/ui/params.ts +15 -1
- package/packages/types/src/meta.ts +4 -0
- package/packages/types/src/session/agentSession.ts +2 -0
- package/packages/types/src/tool/intervention.ts +2 -3
- package/packages/types/src/user/settings/tool.ts +15 -28
- package/packages/utils/src/imageToBase64.ts +17 -10
- package/packages/utils/src/index.ts +1 -1
- package/renovate.json +28 -11
- package/src/app/(backend)/market/agent/[[...segments]]/route.ts +153 -0
- package/src/app/(backend)/market/oidc/[[...segments]]/route.ts +207 -0
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +1 -0
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/PinList/index.tsx +4 -2
- package/src/app/[variants]/(main)/chat/components/topic/features/Topic/TopicListContent/TopicItem/TopicContent.tsx +1 -1
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/Item/Actions.tsx +1 -1
- package/src/app/[variants]/(main)/chat/settings/features/AgentInfoDescription/index.tsx +349 -0
- package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -2
- package/src/app/[variants]/(main)/chat/settings/features/PublishResultModal/index.tsx +64 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishButton.tsx +196 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishModal.tsx +358 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/index.tsx +75 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/AssistantDetailPage.tsx +11 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +12 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Nav.tsx +19 -12
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Related/index.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/index.tsx +43 -29
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Versions/index.tsx +137 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Header.tsx +9 -10
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/AddAgent.tsx +105 -14
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/index.tsx +20 -6
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/StatusPage/index.tsx +113 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +3 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantPage.tsx +4 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/Client.tsx +6 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/index.tsx +7 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/Item.tsx +13 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/MarketSourceSwitch.tsx +64 -0
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +26 -7
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +10 -10
- package/src/app/[variants]/(main)/settings/_layout/type.ts +1 -1
- package/src/app/[variants]/(main)/settings/agent/index.tsx +11 -10
- package/src/app/[variants]/(main)/settings/common/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/page.tsx +13 -10
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/Item.tsx +35 -36
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/SearchResult.tsx +5 -5
- package/src/app/[variants]/(main)/settings/provider/_layout/Desktop/Container.tsx +10 -4
- package/src/app/market-auth-callback/layout.tsx +15 -0
- package/src/app/market-auth-callback/page.tsx +196 -0
- package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +3 -2
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/AgentSetting/store/action.ts +1 -1
- package/src/features/ChatInput/ActionBar/STT/browser.tsx +1 -1
- package/src/features/ChatInput/ActionBar/STT/openai.tsx +1 -1
- package/src/features/Conversation/Messages/Group/GroupChildren.tsx +20 -15
- package/src/features/Conversation/Messages/Group/GroupContext.tsx +15 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/BuiltinPluginTitle.tsx +2 -4
- package/src/features/Conversation/Messages/Group/Tool/Inspector/ToolTitle.tsx +3 -5
- package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +19 -7
- package/src/features/Conversation/Messages/Group/Tool/Render/Arguments/index.tsx +14 -12
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ApprovalActions.tsx +143 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/KeyValueEditor.tsx +213 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ModeSelector.tsx +134 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/index.tsx +99 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/RejectedResponse.tsx +45 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/index.tsx +23 -1
- package/src/features/Conversation/Messages/Group/Tool/index.tsx +42 -18
- package/src/features/Conversation/Messages/Group/Tools.tsx +3 -1
- package/src/features/Conversation/components/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/PluginTag/PluginStatus.tsx +1 -1
- package/src/hooks/useAgentOwnershipCheck.ts +143 -0
- package/src/instrumentation.node.ts +3 -2
- package/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx +364 -0
- package/src/layout/AuthProvider/MarketAuth/errors.ts +75 -0
- package/src/layout/AuthProvider/MarketAuth/index.ts +2 -0
- package/src/layout/AuthProvider/MarketAuth/oidc.ts +382 -0
- package/src/layout/AuthProvider/MarketAuth/types.ts +64 -0
- package/src/layout/AuthProvider/index.tsx +17 -4
- package/src/locales/default/chat.ts +22 -0
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/discover.ts +46 -0
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/marketAuth.ts +42 -0
- package/src/locales/default/setting.ts +94 -1
- package/src/locales/default/topic.ts +1 -0
- package/src/server/globalConfig/genServerAiProviderConfig.test.ts +5 -5
- package/src/server/globalConfig/genServerAiProviderConfig.ts +1 -1
- package/src/server/routers/lambda/market/index.ts +36 -14
- package/src/server/routers/lambda/message.ts +6 -3
- package/src/server/services/discover/index.test.ts +153 -11
- package/src/server/services/discover/index.ts +339 -40
- package/src/server/services/message/index.ts +13 -0
- package/src/server/sitemap.ts +49 -35
- package/src/services/_url.ts +15 -1
- package/src/services/chat/chat.test.ts +5 -5
- package/src/services/chat/clientModelRuntime.test.ts +1 -1
- package/src/services/chat/index.ts +6 -6
- package/src/services/chat/types.ts +1 -2
- package/src/services/discover.ts +16 -5
- package/src/services/electron/remoteServer.ts +8 -1
- package/src/services/marketApi.ts +124 -0
- package/src/services/message/index.ts +17 -2
- package/src/services/models.ts +2 -1
- package/src/store/chat/agents/GeneralChatAgent.ts +141 -24
- package/src/store/chat/agents/__tests__/GeneralChatAgent.test.ts +605 -0
- package/src/store/chat/agents/createAgentExecutors.ts +144 -26
- package/src/store/chat/agents/createToolEngine.ts +22 -0
- package/src/store/chat/slices/aiChat/actions/conversationControl.ts +106 -0
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +54 -26
- package/src/store/chat/slices/message/reducer.ts +2 -1
- package/src/store/chat/slices/plugin/actions/optimisticUpdate.ts +26 -1
- package/src/store/discover/slices/assistant/action.ts +20 -7
- package/src/store/user/slices/settings/action.ts +15 -0
- package/{packages/utils/src → src/utils}/electron/desktopRemoteRPCFetch.ts +1 -1
- package/{packages/utils/src → src/utils/server}/parseModels.ts +1 -2
- package/vitest.config.mts +2 -0
- package/packages/model-runtime/src/utils/imageToBase64.test.ts +0 -91
- package/packages/model-runtime/src/utils/imageToBase64.ts +0 -62
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +0 -98
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/index.tsx +0 -35
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/style.ts +0 -47
- /package/packages/{utils/src/fetch → fetch-sse/src}/headers.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/index.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/request.ts +0 -0
- /package/{packages/utils/src → src/utils/server}/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{packages/utils/src → src/utils/server}/parseModels.test.ts +0 -0
|
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
10
10
|
|
|
11
11
|
import { SESSION_CHAT_URL } from '@/const/url';
|
|
12
12
|
import { useSessionStore } from '@/store/session';
|
|
13
|
+
import type { LobeAgentConfig } from '@/types/agent';
|
|
13
14
|
|
|
14
15
|
import { useDetailContext } from '../../DetailProvider';
|
|
15
16
|
|
|
@@ -21,12 +22,54 @@ const useStyles = createStyles(({ css }) => ({
|
|
|
21
22
|
`,
|
|
22
23
|
}));
|
|
23
24
|
|
|
25
|
+
type MarketAgentModel =
|
|
26
|
+
| LobeAgentConfig['model']
|
|
27
|
+
| {
|
|
28
|
+
model: LobeAgentConfig['model'];
|
|
29
|
+
parameters?: Partial<LobeAgentConfig['params']>;
|
|
30
|
+
provider?: LobeAgentConfig['provider'];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type MarketAgentConfig = Partial<Omit<LobeAgentConfig, 'model' | 'params'>> & {
|
|
34
|
+
model?: MarketAgentModel;
|
|
35
|
+
params?: Partial<LobeAgentConfig['params']>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const normalizeMarketAgentConfig = (
|
|
39
|
+
config?: MarketAgentConfig,
|
|
40
|
+
): Partial<LobeAgentConfig> | undefined => {
|
|
41
|
+
if (!config) return undefined;
|
|
42
|
+
|
|
43
|
+
const { model, params, ...rest } = config;
|
|
44
|
+
const normalized: Partial<LobeAgentConfig> = { ...rest };
|
|
45
|
+
|
|
46
|
+
const modelInfo = model;
|
|
47
|
+
|
|
48
|
+
const mergedParams: Partial<LobeAgentConfig['params']> = {};
|
|
49
|
+
if (typeof modelInfo === 'object' && modelInfo) {
|
|
50
|
+
Object.assign(mergedParams, modelInfo.parameters ?? {});
|
|
51
|
+
normalized.provider = normalized.provider ?? modelInfo.provider;
|
|
52
|
+
normalized.model = modelInfo.model;
|
|
53
|
+
} else {
|
|
54
|
+
normalized.model = modelInfo;
|
|
55
|
+
}
|
|
56
|
+
Object.assign(mergedParams, params ?? {});
|
|
57
|
+
|
|
58
|
+
normalized.params = Object.keys(mergedParams).length > 0 ? mergedParams : undefined;
|
|
59
|
+
|
|
60
|
+
normalized.plugins = normalized.plugins ?? [];
|
|
61
|
+
|
|
62
|
+
return normalized;
|
|
63
|
+
};
|
|
64
|
+
|
|
24
65
|
const AddAgent = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
25
|
-
const { avatar, description, tags, title, config, backgroundColor } =
|
|
66
|
+
const { avatar, description, tags, title, config, backgroundColor, identifier } =
|
|
67
|
+
useDetailContext();
|
|
26
68
|
const { styles } = useStyles();
|
|
27
69
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
70
|
const createSession = useSessionStore((s) => s.createSession);
|
|
29
|
-
const
|
|
71
|
+
const sessions = useSessionStore((s) => s.sessions);
|
|
72
|
+
const { message, modal } = App.useApp();
|
|
30
73
|
const router = useRouter();
|
|
31
74
|
const { t } = useTranslation('discover');
|
|
32
75
|
|
|
@@ -34,29 +77,77 @@ const AddAgent = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
|
34
77
|
avatar,
|
|
35
78
|
backgroundColor,
|
|
36
79
|
description,
|
|
80
|
+
marketIdentifier: identifier,
|
|
37
81
|
tags,
|
|
38
82
|
title,
|
|
39
83
|
};
|
|
40
84
|
|
|
41
|
-
const
|
|
85
|
+
const checkDuplicateAgent = () => {
|
|
86
|
+
if (!identifier) return false;
|
|
87
|
+
return sessions.some((session) => session.meta?.marketIdentifier === identifier);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const showDuplicateConfirmation = (callback: () => void) => {
|
|
91
|
+
modal.confirm({
|
|
92
|
+
cancelText: '取消',
|
|
93
|
+
content: `当前已经添加过「${title}」Agent,是否需要重复添加?`,
|
|
94
|
+
okText: '确认添加',
|
|
95
|
+
onOk: callback,
|
|
96
|
+
title: '重复添加确认',
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const createSessionWithMarketIdentifier = async (isSwitchSession = true) => {
|
|
42
101
|
if (!config) return;
|
|
43
102
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
config,
|
|
103
|
+
const sessionData = {
|
|
104
|
+
config: normalizeMarketAgentConfig(config),
|
|
47
105
|
meta,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const session = await createSession(sessionData, isSwitchSession);
|
|
109
|
+
return session;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleCreateAndConverse = async () => {
|
|
113
|
+
setIsLoading(true);
|
|
114
|
+
try {
|
|
115
|
+
const session = await createSessionWithMarketIdentifier(true);
|
|
116
|
+
message.success(t('assistants.addAgentSuccess'));
|
|
117
|
+
router.push(SESSION_CHAT_URL(session, mobile));
|
|
118
|
+
} finally {
|
|
119
|
+
setIsLoading(false);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleCreate = async () => {
|
|
124
|
+
setIsLoading(true);
|
|
125
|
+
try {
|
|
126
|
+
await createSessionWithMarketIdentifier(false);
|
|
127
|
+
message.success(t('assistants.addAgentSuccess'));
|
|
128
|
+
} finally {
|
|
129
|
+
setIsLoading(false);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleAddAgentAndConverse = async () => {
|
|
134
|
+
if (!config) return;
|
|
135
|
+
|
|
136
|
+
if (checkDuplicateAgent()) {
|
|
137
|
+
showDuplicateConfirmation(handleCreateAndConverse);
|
|
138
|
+
} else {
|
|
139
|
+
await handleCreateAndConverse();
|
|
140
|
+
}
|
|
52
141
|
};
|
|
53
142
|
|
|
54
143
|
const handleAddAgent = async () => {
|
|
55
144
|
if (!config) return;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
145
|
+
|
|
146
|
+
if (checkDuplicateAgent()) {
|
|
147
|
+
showDuplicateConfirmation(handleCreate);
|
|
148
|
+
} else {
|
|
149
|
+
await handleCreate();
|
|
150
|
+
}
|
|
60
151
|
};
|
|
61
152
|
|
|
62
153
|
return (
|
|
@@ -6,29 +6,43 @@ import { Link } from 'react-router-dom';
|
|
|
6
6
|
import urlJoin from 'url-join';
|
|
7
7
|
|
|
8
8
|
import Title from '../../../../../../features/Title';
|
|
9
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
10
|
+
import { AssistantMarketSource } from '@/types/discover';
|
|
9
11
|
import { useDetailContext } from '../../DetailProvider';
|
|
10
12
|
import Item from './Item';
|
|
11
13
|
|
|
12
14
|
const Related = memo(() => {
|
|
13
15
|
const { t } = useTranslation('discover');
|
|
14
16
|
const { related, category } = useDetailContext();
|
|
17
|
+
const { source } = useQuery() as { source?: AssistantMarketSource };
|
|
18
|
+
const marketSource = source === 'legacy' ? 'legacy' : undefined;
|
|
15
19
|
|
|
16
20
|
return (
|
|
17
21
|
<Flexbox gap={16}>
|
|
18
22
|
<Title
|
|
19
23
|
more={t('assistants.details.related.more')}
|
|
20
|
-
moreLink={qs.stringifyUrl(
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
moreLink={qs.stringifyUrl(
|
|
25
|
+
{
|
|
26
|
+
query: {
|
|
27
|
+
category,
|
|
28
|
+
source: marketSource,
|
|
29
|
+
},
|
|
30
|
+
url: '/discover/assistant',
|
|
23
31
|
},
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
{ skipNull: true },
|
|
33
|
+
)}
|
|
26
34
|
>
|
|
27
35
|
{t('assistants.details.related.listTitle')}
|
|
28
36
|
</Title>
|
|
29
37
|
<Flexbox gap={8}>
|
|
30
38
|
{related?.map((item, index) => {
|
|
31
|
-
const link =
|
|
39
|
+
const link = qs.stringifyUrl(
|
|
40
|
+
{
|
|
41
|
+
query: marketSource ? { source: marketSource } : undefined,
|
|
42
|
+
url: urlJoin('/discover/assistant', item.identifier),
|
|
43
|
+
},
|
|
44
|
+
{ skipNull: true },
|
|
45
|
+
);
|
|
32
46
|
return (
|
|
33
47
|
<Link key={index} style={{ color: 'inherit', overflow: 'hidden' }} to={link}>
|
|
34
48
|
<Item {...item} />
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ClockCircleOutlined,
|
|
5
|
+
ExclamationCircleOutlined,
|
|
6
|
+
FolderOpenOutlined,
|
|
7
|
+
} from '@ant-design/icons';
|
|
8
|
+
import { Button, Result } from 'antd';
|
|
9
|
+
import { useRouter } from 'next/navigation';
|
|
10
|
+
import { memo } from 'react';
|
|
11
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
12
|
+
|
|
13
|
+
interface StatusPageProps {
|
|
14
|
+
status: 'unpublished' | 'archived' | 'deprecated';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const StatusPage = memo<StatusPageProps>(({ status }) => {
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const { t } = useTranslation('discover');
|
|
20
|
+
|
|
21
|
+
const handleBackToMarket = () => {
|
|
22
|
+
router.push('/discover/assistant');
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// 审核中状态
|
|
26
|
+
if (status === 'unpublished') {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
style={{
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flex: 1,
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
minHeight: '60vh',
|
|
35
|
+
padding: '20px',
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<Result
|
|
39
|
+
extra={
|
|
40
|
+
<Button onClick={handleBackToMarket} type="primary">
|
|
41
|
+
{t('assistants.status.backToMarket')}
|
|
42
|
+
</Button>
|
|
43
|
+
}
|
|
44
|
+
icon={<ClockCircleOutlined style={{ color: '#faad14' }} />}
|
|
45
|
+
subTitle={
|
|
46
|
+
<div style={{ color: '#666', lineHeight: 1.6 }}>
|
|
47
|
+
<Trans i18nKey="assistants.status.unpublished.subtitle" ns="discover">
|
|
48
|
+
当前访问的助手正在进行版本审核中,如果有疑问复制链接发送问题到{' '}
|
|
49
|
+
<a href="mailto:support@lobehub.com" style={{ color: '#1890ff' }}>
|
|
50
|
+
support@lobehub.com
|
|
51
|
+
</a>{' '}
|
|
52
|
+
进行咨询。
|
|
53
|
+
</Trans>
|
|
54
|
+
</div>
|
|
55
|
+
}
|
|
56
|
+
title={t('assistants.status.unpublished.title')}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 归档/拒绝状态
|
|
63
|
+
const isArchived = status === 'archived';
|
|
64
|
+
const statusKey = isArchived ? 'archived' : 'deprecated';
|
|
65
|
+
const statusIcon = isArchived ? (
|
|
66
|
+
<FolderOpenOutlined style={{ color: '#8c8c8c' }} />
|
|
67
|
+
) : (
|
|
68
|
+
<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
style={{
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
display: 'flex',
|
|
76
|
+
flex: 1,
|
|
77
|
+
justifyContent: 'center',
|
|
78
|
+
minHeight: '60vh',
|
|
79
|
+
padding: '20px',
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<Result
|
|
83
|
+
extra={
|
|
84
|
+
<Button onClick={handleBackToMarket} type="primary">
|
|
85
|
+
{t('assistants.status.backToMarket')}
|
|
86
|
+
</Button>
|
|
87
|
+
}
|
|
88
|
+
icon={statusIcon}
|
|
89
|
+
subTitle={
|
|
90
|
+
<div style={{ color: '#666', lineHeight: 1.6 }}>
|
|
91
|
+
<p>{t(`assistants.status.${statusKey}.subtitle`)}</p>
|
|
92
|
+
<ul style={{ margin: '16px 0', paddingLeft: '20px', textAlign: 'left' }}>
|
|
93
|
+
<li>{t(`assistants.status.${statusKey}.reasons.owner`)}</li>
|
|
94
|
+
<li>{t(`assistants.status.${statusKey}.reasons.official`)}</li>
|
|
95
|
+
</ul>
|
|
96
|
+
<p>
|
|
97
|
+
<Trans i18nKey="assistants.status.support" ns="discover">
|
|
98
|
+
有各种问题请复制链接发送到{' '}
|
|
99
|
+
<a href="mailto:support@lobehub.com" style={{ color: '#1890ff' }}>
|
|
100
|
+
support@lobehub.com
|
|
101
|
+
</a>{' '}
|
|
102
|
+
进行咨询。
|
|
103
|
+
</Trans>
|
|
104
|
+
</p>
|
|
105
|
+
</div>
|
|
106
|
+
}
|
|
107
|
+
title={t(`assistants.status.${statusKey}.title`)}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export default StatusPage;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
import { CopyButton } from '@lobehub/ui';
|
|
4
4
|
import { Breadcrumb as AntdBreadcrumb } from 'antd';
|
|
5
5
|
import { useTheme } from 'antd-style';
|
|
6
|
+
import Link from 'next/link';
|
|
6
7
|
import { memo } from 'react';
|
|
7
8
|
import { useTranslation } from 'react-i18next';
|
|
8
9
|
import { Flexbox } from 'react-layout-kit';
|
|
9
|
-
import
|
|
10
|
+
import urlJoin from 'url-join';
|
|
10
11
|
|
|
11
12
|
import { DiscoverTab } from '@/types/discover';
|
|
12
13
|
|
|
@@ -17,11 +18,11 @@ const Breadcrumb = memo<{ identifier: string; tab: DiscoverTab }>(({ tab, identi
|
|
|
17
18
|
<AntdBreadcrumb
|
|
18
19
|
items={[
|
|
19
20
|
{
|
|
20
|
-
title: <Link
|
|
21
|
+
title: <Link href={'/discover'}>Discover</Link>,
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
title: (
|
|
24
|
-
<Link
|
|
25
|
+
<Link href={urlJoin('/discover', tab)}>
|
|
25
26
|
{tab === DiscoverTab.Mcp ? 'MCP Servers' : t(`tab.${tab}` as any)}
|
|
26
27
|
</Link>
|
|
27
28
|
),
|
|
@@ -14,6 +14,7 @@ import { DiscoverTab } from '@/types/discover';
|
|
|
14
14
|
import { MAX_WIDTH, SCROLL_PARENT_ID } from '../../../features/const';
|
|
15
15
|
import { useNav } from '../../../features/useNav';
|
|
16
16
|
import SortButton from '../../features/SortButton';
|
|
17
|
+
import MarketSourceSwitch from '../../assistant/features/MarketSourceSwitch';
|
|
17
18
|
import { useScroll } from './useScroll';
|
|
18
19
|
|
|
19
20
|
export const useStyles = createStyles(({ cx, stylish, css, token }) => ({
|
|
@@ -88,7 +89,8 @@ const Nav = memo(() => {
|
|
|
88
89
|
/>
|
|
89
90
|
</Flexbox>
|
|
90
91
|
{!isHome && (
|
|
91
|
-
<Flexbox align={'center'} gap={
|
|
92
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
93
|
+
{activeKey === DiscoverTab.Assistants && <MarketSourceSwitch />}
|
|
92
94
|
<SortButton />
|
|
93
95
|
</Flexbox>
|
|
94
96
|
)}
|
|
@@ -13,7 +13,7 @@ import List from './features/List';
|
|
|
13
13
|
import Loading from './loading';
|
|
14
14
|
|
|
15
15
|
const AssistantPage = memo<{ mobile?: boolean }>(() => {
|
|
16
|
-
const { q, page, category, sort, order } = useQuery() as AssistantQueryParams;
|
|
16
|
+
const { q, page, category, sort, order, source } = useQuery() as AssistantQueryParams;
|
|
17
17
|
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
|
|
18
18
|
const { data, isLoading } = useAssistantList({
|
|
19
19
|
category,
|
|
@@ -22,8 +22,11 @@ const AssistantPage = memo<{ mobile?: boolean }>(() => {
|
|
|
22
22
|
pageSize: 21,
|
|
23
23
|
q,
|
|
24
24
|
sort,
|
|
25
|
+
source,
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
console.log("data",data)
|
|
29
|
+
|
|
27
30
|
if (isLoading || !data) return <Loading />;
|
|
28
31
|
|
|
29
32
|
const { items, currentPage, pageSize, totalCount } = data;
|
|
@@ -6,22 +6,26 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
6
6
|
import { withSuspense } from '@/components/withSuspense';
|
|
7
7
|
import { useQuery } from '@/hooks/useQuery';
|
|
8
8
|
import { useDiscoverStore } from '@/store/discover';
|
|
9
|
-
import { AssistantQueryParams, DiscoverTab } from '@/types/discover';
|
|
9
|
+
import { AssistantMarketSource, AssistantQueryParams, DiscoverTab } from '@/types/discover';
|
|
10
10
|
|
|
11
11
|
import Pagination from '../features/Pagination';
|
|
12
12
|
import List from './features/List';
|
|
13
13
|
import Loading from './loading';
|
|
14
14
|
|
|
15
15
|
const Client = memo<{ mobile?: boolean }>(() => {
|
|
16
|
-
const { q, page, category, sort, order } =
|
|
16
|
+
const { q, page, category, sort, order, ownerId, source } =
|
|
17
|
+
useQuery() as AssistantQueryParams;
|
|
18
|
+
const marketSource = (source as AssistantMarketSource | undefined) ?? 'new';
|
|
17
19
|
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
|
|
18
20
|
const { data, isLoading } = useAssistantList({
|
|
19
21
|
category,
|
|
20
22
|
order,
|
|
23
|
+
ownerId,
|
|
21
24
|
page,
|
|
22
25
|
pageSize: 21,
|
|
23
26
|
q,
|
|
24
27
|
sort,
|
|
28
|
+
source: marketSource,
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
if (isLoading || !data) return <Loading />;
|
|
@@ -16,15 +16,19 @@ import { useCategory } from './useCategory';
|
|
|
16
16
|
|
|
17
17
|
const Category = memo(() => {
|
|
18
18
|
const useAssistantCategories = useDiscoverStore((s) => s.useAssistantCategories);
|
|
19
|
-
const {
|
|
20
|
-
|
|
19
|
+
const {
|
|
20
|
+
category = 'all',
|
|
21
|
+
q,
|
|
22
|
+
source,
|
|
23
|
+
} = useQuery() as { category?: AssistantCategory; q?: string; source?: string };
|
|
24
|
+
const { data: items = [] } = useAssistantCategories({ q, source: source as any });
|
|
21
25
|
const navigate = useNavigate();
|
|
22
26
|
const cates = useCategory();
|
|
23
27
|
|
|
24
28
|
const genUrl = (key: AssistantCategory) =>
|
|
25
29
|
qs.stringifyUrl(
|
|
26
30
|
{
|
|
27
|
-
query: { category: key === AssistantCategory.All ? null : key, q },
|
|
31
|
+
query: { category: key === AssistantCategory.All ? null : key, q, source },
|
|
28
32
|
url: '/assistant',
|
|
29
33
|
},
|
|
30
34
|
{ skipNull: true },
|
|
@@ -2,6 +2,7 @@ import { Github } from '@lobehub/icons';
|
|
|
2
2
|
import { ActionIcon, Avatar, Block, Icon, Text } from '@lobehub/ui';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { ClockIcon } from 'lucide-react';
|
|
5
|
+
import qs from 'query-string';
|
|
5
6
|
import { memo } from 'react';
|
|
6
7
|
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -9,7 +10,8 @@ import { Link, useNavigate } from 'react-router-dom';
|
|
|
9
10
|
import urlJoin from 'url-join';
|
|
10
11
|
|
|
11
12
|
import PublishedTime from '@/components/PublishedTime';
|
|
12
|
-
import {
|
|
13
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
14
|
+
import { AssistantMarketSource, DiscoverAssistantItem } from '@/types/discover';
|
|
13
15
|
|
|
14
16
|
import TokenTag from './TokenTag';
|
|
15
17
|
|
|
@@ -61,9 +63,18 @@ const AssistantItem = memo<DiscoverAssistantItem>(
|
|
|
61
63
|
knowledgeCount,
|
|
62
64
|
backgroundColor,
|
|
63
65
|
}) => {
|
|
66
|
+
|
|
67
|
+
console.log("author",author)
|
|
64
68
|
const { styles, theme } = useStyles();
|
|
65
69
|
const navigate = useNavigate();
|
|
66
|
-
const
|
|
70
|
+
const { source } = useQuery() as { source?: AssistantMarketSource };
|
|
71
|
+
const link = qs.stringifyUrl(
|
|
72
|
+
{
|
|
73
|
+
query: { source },
|
|
74
|
+
url: urlJoin('/assistant', identifier),
|
|
75
|
+
},
|
|
76
|
+
{ skipNull: true },
|
|
77
|
+
);
|
|
67
78
|
const { t } = useTranslation('discover');
|
|
68
79
|
|
|
69
80
|
return (
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Dropdown, DropdownMenuItemType, Icon } from '@lobehub/ui';
|
|
4
|
+
import { Button } from 'antd';
|
|
5
|
+
import { ChevronDown, Store } from 'lucide-react';
|
|
6
|
+
import { memo, useMemo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
10
|
+
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
|
11
|
+
import { AssistantMarketSource } from '@/types/discover';
|
|
12
|
+
|
|
13
|
+
const MarketSourceSwitch = memo(() => {
|
|
14
|
+
const { t } = useTranslation('discover');
|
|
15
|
+
const router = useQueryRoute();
|
|
16
|
+
const query = useQuery() as { source?: AssistantMarketSource };
|
|
17
|
+
const currentSource = (query.source as AssistantMarketSource) ?? 'new';
|
|
18
|
+
|
|
19
|
+
const items = useMemo(
|
|
20
|
+
() =>
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
key: 'new',
|
|
24
|
+
label: t('assistants.marketSource.new'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: 'legacy',
|
|
28
|
+
label: t('assistants.marketSource.legacy'),
|
|
29
|
+
},
|
|
30
|
+
] satisfies DropdownMenuItemType[],
|
|
31
|
+
[t],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const handleChange = (value: AssistantMarketSource) => {
|
|
35
|
+
router.push('/discover/assistant', {
|
|
36
|
+
query: {
|
|
37
|
+
page: null,
|
|
38
|
+
source: value === 'new' ? null : value,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Dropdown
|
|
45
|
+
menu={{
|
|
46
|
+
// @ts-expect-error 等待 antd 修复
|
|
47
|
+
activeKey: currentSource,
|
|
48
|
+
items,
|
|
49
|
+
onClick: ({ key }) => handleChange(key as AssistantMarketSource),
|
|
50
|
+
}}
|
|
51
|
+
trigger={['click', 'hover']}
|
|
52
|
+
>
|
|
53
|
+
<Button icon={<Icon icon={Store} />} type={'text'}>
|
|
54
|
+
{t('assistants.marketSource.label')}:{' '}
|
|
55
|
+
{items.find((item) => item.key === currentSource)?.label}
|
|
56
|
+
<Icon icon={ChevronDown} />
|
|
57
|
+
</Button>
|
|
58
|
+
</Dropdown>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
MarketSourceSwitch.displayName = 'MarketSourceSwitch';
|
|
63
|
+
|
|
64
|
+
export default MarketSourceSwitch;
|
|
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
|
|
8
8
|
import { useQuery } from '@/hooks/useQuery';
|
|
9
9
|
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
|
10
|
+
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
|
|
10
11
|
import {
|
|
11
12
|
AssistantSorts,
|
|
12
13
|
DiscoverTab,
|
|
@@ -21,11 +22,12 @@ const SortButton = memo(() => {
|
|
|
21
22
|
const pathname = usePathname();
|
|
22
23
|
const { sort } = useQuery();
|
|
23
24
|
const router = useQueryRoute();
|
|
25
|
+
const { isAuthenticated, getCurrentUserInfo } = useMarketAuth();
|
|
24
26
|
const activeTab = useMemo(() => pathname.split('discover/')[1] as DiscoverTab, [pathname]);
|
|
25
27
|
const items = useMemo(() => {
|
|
26
28
|
switch (activeTab) {
|
|
27
29
|
case DiscoverTab.Assistants: {
|
|
28
|
-
|
|
30
|
+
const baseItems = [
|
|
29
31
|
{
|
|
30
32
|
key: AssistantSorts.CreatedAt,
|
|
31
33
|
label: t('assistants.sorts.createdAt'),
|
|
@@ -51,6 +53,16 @@ const SortButton = memo(() => {
|
|
|
51
53
|
label: t('assistants.sorts.knowledgeCount'),
|
|
52
54
|
},
|
|
53
55
|
];
|
|
56
|
+
|
|
57
|
+
// Only add "My Own" option if user is authenticated
|
|
58
|
+
if (isAuthenticated) {
|
|
59
|
+
baseItems.push({
|
|
60
|
+
key: AssistantSorts.MyOwn,
|
|
61
|
+
label: t('assistants.sorts.myown'),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return baseItems;
|
|
54
66
|
}
|
|
55
67
|
case DiscoverTab.Plugins: {
|
|
56
68
|
return [
|
|
@@ -144,7 +156,7 @@ const SortButton = memo(() => {
|
|
|
144
156
|
return [];
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
|
-
}, [t, activeTab]);
|
|
159
|
+
}, [t, activeTab, isAuthenticated]);
|
|
148
160
|
|
|
149
161
|
const activeItem: any = useMemo(() => {
|
|
150
162
|
if (sort) {
|
|
@@ -155,11 +167,18 @@ const SortButton = memo(() => {
|
|
|
155
167
|
}, [items, sort]);
|
|
156
168
|
|
|
157
169
|
const handleSort = (config: string) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
const query: any = { sort: config };
|
|
171
|
+
|
|
172
|
+
// If "My Own" is selected, add ownerId to query
|
|
173
|
+
if (config === AssistantSorts.MyOwn) {
|
|
174
|
+
const userInfo = getCurrentUserInfo();
|
|
175
|
+
console.log('userInfo', userInfo);
|
|
176
|
+
if (userInfo?.accountId) {
|
|
177
|
+
query.ownerId = userInfo.accountId;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
router.push(pathname, { query });
|
|
163
182
|
};
|
|
164
183
|
|
|
165
184
|
if (items?.length === 0) return null;
|
|
@@ -34,16 +34,16 @@ const Layout = memo<LayoutProps>(({ children, category }) => {
|
|
|
34
34
|
{category}
|
|
35
35
|
</Header>
|
|
36
36
|
)}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
<SettingContainer
|
|
38
|
+
addonAfter={<Footer />}
|
|
39
|
+
style={{
|
|
40
|
+
paddingBlock: 24,
|
|
41
|
+
paddingInline: 32,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</SettingContainer>
|
|
46
|
+
</Flexbox>
|
|
47
47
|
);
|
|
48
48
|
});
|
|
49
49
|
|