@lobehub/chat 0.150.9 → 0.151.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.
- package/.env.example +3 -0
- package/CHANGELOG.md +50 -0
- package/Dockerfile +3 -0
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/docs/self-hosting/environment-variables/model-provider.mdx +9 -0
- package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +9 -0
- package/docs/usage/features/multi-ai-providers.mdx +1 -0
- package/docs/usage/features/multi-ai-providers.zh-CN.mdx +1 -0
- package/locales/ar/error.json +2 -0
- package/locales/ar/modelProvider.json +12 -0
- package/locales/bg-BG/error.json +2 -0
- package/locales/bg-BG/modelProvider.json +12 -0
- package/locales/de-DE/error.json +2 -0
- package/locales/de-DE/modelProvider.json +12 -0
- package/locales/en-US/error.json +2 -0
- package/locales/en-US/modelProvider.json +12 -0
- package/locales/es-ES/error.json +2 -0
- package/locales/es-ES/modelProvider.json +12 -0
- package/locales/fr-FR/error.json +2 -0
- package/locales/fr-FR/modelProvider.json +12 -0
- package/locales/it-IT/error.json +2 -0
- package/locales/it-IT/modelProvider.json +12 -0
- package/locales/ja-JP/error.json +2 -0
- package/locales/ja-JP/modelProvider.json +12 -0
- package/locales/ko-KR/error.json +2 -0
- package/locales/ko-KR/modelProvider.json +12 -0
- package/locales/nl-NL/error.json +2 -0
- package/locales/nl-NL/modelProvider.json +12 -0
- package/locales/pl-PL/error.json +2 -0
- package/locales/pl-PL/modelProvider.json +12 -0
- package/locales/pt-BR/error.json +2 -0
- package/locales/pt-BR/modelProvider.json +12 -0
- package/locales/ru-RU/error.json +2 -0
- package/locales/ru-RU/modelProvider.json +12 -0
- package/locales/tr-TR/error.json +2 -0
- package/locales/tr-TR/modelProvider.json +12 -0
- package/locales/vi-VN/error.json +2 -0
- package/locales/vi-VN/modelProvider.json +12 -0
- package/locales/zh-CN/error.json +2 -0
- package/locales/zh-CN/modelProvider.json +12 -0
- package/locales/zh-TW/error.json +2 -0
- package/locales/zh-TW/modelProvider.json +12 -0
- package/package.json +1 -1
- package/src/app/api/chat/agentRuntime.test.ts +17 -0
- package/src/app/api/chat/agentRuntime.ts +7 -0
- package/src/app/api/chat/minimax/route.test.ts +24 -0
- package/src/app/api/chat/minimax/route.ts +5 -0
- package/src/app/api/errorResponse.test.ts +6 -0
- package/src/app/api/errorResponse.ts +3 -0
- package/src/app/chat/(desktop)/features/ChatHeader/Tags.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/Footer/DragUpload.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/Footer/SendMore.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/TextArea.test.tsx +5 -5
- package/src/app/chat/(desktop)/features/ChatInput/TextArea.tsx +3 -3
- package/src/app/chat/(mobile)/features/SessionHeader.tsx +3 -3
- package/src/app/chat/features/ShareButton/ShareModal.tsx +3 -3
- package/src/app/chat/features/TelemetryNotification/index.tsx +2 -2
- package/src/app/chat/features/TopicListContent/Topic/index.tsx +2 -2
- package/src/app/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +3 -3
- package/src/app/settings/(mobile)/index.tsx +3 -3
- package/src/app/settings/about/Analytics.tsx +4 -4
- package/src/app/settings/agent/Agent.tsx +4 -4
- package/src/app/settings/common/Common.tsx +4 -4
- package/src/app/settings/common/Theme.tsx +4 -4
- package/src/app/settings/features/ThemeSwatches/ThemeSwatchesNeutral.tsx +3 -3
- package/src/app/settings/features/ThemeSwatches/ThemeSwatchesPrimary.tsx +3 -3
- package/src/app/settings/hooks/useSyncSettings.ts +3 -3
- package/src/app/settings/llm/Azure/index.tsx +3 -3
- package/src/app/settings/llm/Minimax/index.tsx +26 -0
- package/src/app/settings/llm/components/ProviderConfig/index.tsx +3 -3
- package/src/app/settings/llm/components/ProviderModelList/CustomModelOption.tsx +4 -4
- package/src/app/settings/llm/components/ProviderModelList/ModelConfigModal.tsx +4 -4
- package/src/app/settings/llm/components/ProviderModelList/ModelFetcher.tsx +6 -6
- package/src/app/settings/llm/components/ProviderModelList/Option.tsx +3 -3
- package/src/app/settings/llm/components/ProviderModelList/index.tsx +6 -6
- package/src/app/settings/llm/index.tsx +2 -0
- package/src/app/settings/sync/Alert.tsx +3 -3
- package/src/app/settings/sync/DeviceInfo/DeviceName.tsx +3 -3
- package/src/app/settings/sync/WebRTC/index.tsx +2 -2
- package/src/app/settings/sync/components/SystemIcon.tsx +0 -1
- package/src/app/settings/tts/TTS/index.tsx +4 -4
- package/src/chains/__tests__/summaryAgentName.test.ts +2 -2
- package/src/chains/__tests__/summaryDescription.test.ts +2 -2
- package/src/chains/__tests__/summaryTags.test.ts +2 -2
- package/src/chains/__tests__/summaryTitle.test.ts +2 -2
- package/src/chains/summaryAgentName.ts +1 -1
- package/src/chains/summaryDescription.ts +1 -1
- package/src/chains/summaryTags.ts +1 -1
- package/src/chains/summaryTitle.ts +1 -1
- package/src/components/ModelIcon/index.tsx +7 -17
- package/src/components/ModelProviderIcon/index.tsx +5 -0
- package/src/components/ModelTag/ModelIcon.tsx +1 -0
- package/src/config/modelProviders/index.ts +4 -0
- package/src/config/modelProviders/minimax.ts +30 -0
- package/src/config/server/provider.ts +9 -0
- package/src/const/settings/index.ts +6 -0
- package/src/features/AgentSetting/AgentConfig/ModelSelect.tsx +3 -6
- package/src/features/AgentSetting/AgentMeta/index.tsx +3 -3
- package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +4 -4
- package/src/features/AgentSetting/AgentTTS/index.tsx +3 -3
- package/src/features/AvatarWithUpload/index.tsx +3 -3
- package/src/features/ChatInput/ActionBar/FileUpload.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +4 -4
- package/src/features/ChatInput/ActionBar/Token/index.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Tools/index.tsx +3 -3
- package/src/features/ChatInput/STT/browser.tsx +4 -4
- package/src/features/ChatInput/STT/index.tsx +3 -3
- package/src/features/ChatInput/STT/openai.tsx +4 -4
- package/src/features/ChatInput/useChatInput.ts +3 -3
- package/src/features/Conversation/Error/APIKeyForm/Bedrock.tsx +3 -3
- package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +3 -3
- package/src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx +5 -0
- package/src/features/Conversation/Error/AccessCodeForm.tsx +3 -3
- package/src/features/Conversation/Error/index.tsx +1 -0
- package/src/features/Conversation/Extras/TTS/index.tsx +3 -3
- package/src/features/Conversation/Plugins/Render/MarkdownType/index.tsx +3 -3
- package/src/features/Conversation/components/ChatItem/index.tsx +3 -3
- package/src/features/ModelSwitchPanel/index.tsx +3 -6
- package/src/features/PluginDevModal/LocalForm.tsx +3 -3
- package/src/features/SyncStatusInspector/DisableSync.tsx +3 -3
- package/src/features/SyncStatusInspector/EnableSync.tsx +4 -4
- package/src/features/SyncStatusInspector/index.tsx +2 -2
- package/src/hooks/_header.ts +4 -4
- package/src/hooks/useSyncData.ts +3 -3
- package/src/hooks/useTTS.ts +4 -4
- package/src/layout/DefaultLayout/Desktop/SideBar/BottomActions.tsx +2 -2
- package/src/layout/DefaultLayout/Desktop/SideBar/TopActions.tsx +2 -2
- package/src/layout/DefaultLayout/Mobile/index.tsx +1 -1
- package/src/layout/GlobalProvider/AppTheme.tsx +4 -4
- package/src/layout/GlobalProvider/StoreInitialization.tsx +6 -1
- package/src/libs/agent-runtime/AgentRuntime.ts +7 -0
- package/src/libs/agent-runtime/error.ts +3 -0
- package/src/libs/agent-runtime/index.ts +1 -0
- package/src/libs/agent-runtime/minimax/index.test.ts +261 -0
- package/src/libs/agent-runtime/minimax/index.ts +185 -0
- package/src/libs/agent-runtime/togetherai/type.ts +0 -1
- package/src/libs/agent-runtime/types/type.ts +1 -0
- package/src/locales/default/error.ts +3 -0
- package/src/locales/default/modelProvider.ts +12 -0
- package/src/migrations/FromV3ToV4/types/v3.ts +1 -0
- package/src/services/__tests__/chat.test.ts +17 -20
- package/src/services/__tests__/tool.test.ts +2 -2
- package/src/services/_auth.test.ts +2 -2
- package/src/services/_auth.ts +7 -7
- package/src/services/_header.ts +4 -4
- package/src/services/chat.ts +13 -13
- package/src/services/config.ts +4 -4
- package/src/services/models.ts +3 -3
- package/src/services/ollama.ts +3 -3
- package/src/services/session/client.ts +2 -2
- package/src/services/tool.ts +1 -1
- package/src/services/trace.ts +3 -3
- package/src/store/agent/slices/chat/selectors.test.ts +2 -2
- package/src/store/chat/slices/message/selectors.test.ts +1 -1
- package/src/store/chat/slices/message/selectors.ts +3 -3
- package/src/store/global/{slices/preference/action.test.ts → action.test.ts} +65 -13
- package/src/store/global/{slices/preference/action.ts → action.ts} +30 -16
- package/src/store/global/initialState.ts +58 -8
- package/src/store/global/selectors.ts +9 -8
- package/src/store/global/store.ts +3 -7
- package/src/store/market/action.ts +1 -1
- package/src/store/session/slices/session/action.ts +3 -3
- package/src/store/{global → user}/helpers.ts +2 -2
- package/src/store/user/index.ts +1 -0
- package/src/store/user/initialState.ts +11 -0
- package/src/store/user/selectors.ts +8 -0
- package/src/store/{global → user}/slices/common/action.test.ts +29 -81
- package/src/store/{global → user}/slices/common/action.ts +2 -20
- package/src/store/user/slices/common/initialState.ts +18 -0
- package/src/store/user/slices/common/selectors.ts +6 -0
- package/src/store/user/slices/preference/action.test.ts +41 -0
- package/src/store/user/slices/preference/action.ts +50 -0
- package/src/store/user/slices/preference/initialState.ts +33 -0
- package/src/store/user/slices/preference/selectors.ts +13 -0
- package/src/store/{global → user}/slices/settings/actions/general.test.ts +6 -6
- package/src/store/{global → user}/slices/settings/actions/general.ts +2 -2
- package/src/store/{global → user}/slices/settings/actions/index.ts +2 -2
- package/src/store/{global → user}/slices/settings/actions/llm.test.ts +11 -14
- package/src/store/{global → user}/slices/settings/actions/llm.ts +4 -2
- package/src/store/{global → user}/slices/settings/initialState.ts +2 -2
- package/src/store/{global → user}/slices/settings/selectors/modelConfig.test.ts +8 -8
- package/src/store/{global → user}/slices/settings/selectors/modelConfig.ts +12 -12
- package/src/store/{global → user}/slices/settings/selectors/modelProvider.test.ts +17 -17
- package/src/store/{global → user}/slices/settings/selectors/modelProvider.ts +19 -20
- package/src/store/{global → user}/slices/settings/selectors/selectors.test.ts +8 -8
- package/src/store/{global → user}/slices/settings/selectors/settings.ts +12 -12
- package/src/store/user/slices/settings/selectors/sync.ts +14 -0
- package/src/store/user/store.ts +33 -0
- package/src/tools/dalle/Render/ToolBar.tsx +3 -3
- package/src/types/settings/modelProvider.ts +1 -0
- package/src/utils/localStorage.ts +3 -1
- package/src/store/global/slices/common/initialState.ts +0 -42
- package/src/store/global/slices/common/selectors.ts +0 -6
- package/src/store/global/slices/preference/initialState.ts +0 -51
- package/src/store/global/slices/preference/selectors.ts +0 -18
- package/src/store/global/slices/settings/selectors/sync.ts +0 -14
- /package/src/store/{global → user}/slices/settings/reducers/customModelCard.test.ts +0 -0
- /package/src/store/{global → user}/slices/settings/reducers/customModelCard.ts +0 -0
- /package/src/store/{global → user}/slices/settings/selectors/__snapshots__/selectors.test.ts.snap +0 -0
- /package/src/store/{global → user}/slices/settings/selectors/index.ts +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModelProviderCard } from '@/types/llm';
|
|
2
|
+
|
|
3
|
+
const Minimax: ModelProviderCard = {
|
|
4
|
+
chatModels: [
|
|
5
|
+
{
|
|
6
|
+
description: '更复杂的格式化文本生成',
|
|
7
|
+
displayName: 'abab6',
|
|
8
|
+
enabled: true,
|
|
9
|
+
id: 'abab6-chat',
|
|
10
|
+
tokens: 32_768,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
description: '生产力场景',
|
|
14
|
+
displayName: 'abab5.5',
|
|
15
|
+
enabled: true,
|
|
16
|
+
id: 'abab5.5-chat',
|
|
17
|
+
tokens: 16_384,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
description: '人设对话场景',
|
|
21
|
+
displayName: 'abab5.5s',
|
|
22
|
+
enabled: true,
|
|
23
|
+
id: 'abab5.5s-chat',
|
|
24
|
+
tokens: 8192,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
id: 'minimax',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default Minimax;
|
|
@@ -43,6 +43,10 @@ declare global {
|
|
|
43
43
|
ANTHROPIC_API_KEY?: string;
|
|
44
44
|
ANTHROPIC_PROXY_URL?: string;
|
|
45
45
|
|
|
46
|
+
// Minimax Provider
|
|
47
|
+
ENABLED_MINIMAX?: string;
|
|
48
|
+
MINIMAX_API_KEY?: string;
|
|
49
|
+
|
|
46
50
|
// Mistral Provider
|
|
47
51
|
ENABLED_MISTRAL?: string;
|
|
48
52
|
MISTRAL_API_KEY?: string;
|
|
@@ -109,6 +113,8 @@ export const getProviderConfig = () => {
|
|
|
109
113
|
|
|
110
114
|
const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || '';
|
|
111
115
|
|
|
116
|
+
const MINIMAX_API_KEY = process.env.MINIMAX_API_KEY || '';
|
|
117
|
+
|
|
112
118
|
const MISTRAL_API_KEY = process.env.MISTRAL_API_KEY || '';
|
|
113
119
|
|
|
114
120
|
const GROQ_API_KEY = process.env.GROQ_API_KEY || '';
|
|
@@ -171,6 +177,9 @@ export const getProviderConfig = () => {
|
|
|
171
177
|
ANTHROPIC_API_KEY,
|
|
172
178
|
ANTHROPIC_PROXY_URL: process.env.ANTHROPIC_PROXY_URL,
|
|
173
179
|
|
|
180
|
+
ENABLED_MINIMAX: !!MINIMAX_API_KEY,
|
|
181
|
+
MINIMAX_API_KEY,
|
|
182
|
+
|
|
174
183
|
ENABLED_MISTRAL: !!MISTRAL_API_KEY,
|
|
175
184
|
MISTRAL_API_KEY,
|
|
176
185
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
BedrockProviderCard,
|
|
4
4
|
GoogleProviderCard,
|
|
5
5
|
GroqProviderCard,
|
|
6
|
+
MinimaxProviderCard,
|
|
6
7
|
MistralProviderCard,
|
|
7
8
|
MoonshotProviderCard,
|
|
8
9
|
OllamaProviderCard,
|
|
@@ -90,6 +91,11 @@ export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
|
|
|
90
91
|
enabled: false,
|
|
91
92
|
enabledModels: filterEnabledModels(GroqProviderCard),
|
|
92
93
|
},
|
|
94
|
+
minimax: {
|
|
95
|
+
apiKey: '',
|
|
96
|
+
enabled: false,
|
|
97
|
+
enabledModels: filterEnabledModels(MinimaxProviderCard),
|
|
98
|
+
},
|
|
93
99
|
mistral: {
|
|
94
100
|
apiKey: '',
|
|
95
101
|
enabled: false,
|
|
@@ -4,8 +4,8 @@ import isEqual from 'fast-deep-equal';
|
|
|
4
4
|
import { memo, useMemo } from 'react';
|
|
5
5
|
|
|
6
6
|
import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
|
|
7
|
-
import {
|
|
8
|
-
import { modelProviderSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
9
9
|
import { ModelProviderCard } from '@/types/llm';
|
|
10
10
|
|
|
11
11
|
import { useStore } from '../store';
|
|
@@ -25,10 +25,7 @@ interface ModelOption {
|
|
|
25
25
|
|
|
26
26
|
const ModelSelect = memo(() => {
|
|
27
27
|
const [model, updateConfig] = useStore((s) => [s.config.model, s.setAgentConfig]);
|
|
28
|
-
const enabledList =
|
|
29
|
-
modelProviderSelectors.modelProviderListForModelSelect,
|
|
30
|
-
isEqual,
|
|
31
|
-
);
|
|
28
|
+
const enabledList = useUserStore(modelProviderSelectors.modelProviderListForModelSelect, isEqual);
|
|
32
29
|
|
|
33
30
|
const { styles } = useStyles();
|
|
34
31
|
|
|
@@ -8,8 +8,8 @@ import { memo, useMemo } from 'react';
|
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
|
-
import {
|
|
12
|
-
import { settingsSelectors } from '@/store/
|
|
11
|
+
import { useUserStore } from '@/store/user';
|
|
12
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
13
13
|
|
|
14
14
|
import { useStore } from '../store';
|
|
15
15
|
import { SessionLoadingState } from '../store/initialState';
|
|
@@ -28,7 +28,7 @@ const AgentMeta = memo(() => {
|
|
|
28
28
|
s.autocompleteMeta,
|
|
29
29
|
s.autocompleteAllMeta,
|
|
30
30
|
]);
|
|
31
|
-
const locale =
|
|
31
|
+
const locale = useUserStore(settingsSelectors.currentLanguage);
|
|
32
32
|
const loading = useStore((s) => s.autocompleteLoading);
|
|
33
33
|
const meta = useStore((s) => s.meta, isEqual);
|
|
34
34
|
|
|
@@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
|
5
5
|
|
|
6
6
|
import { useTokenCount } from '@/hooks/useTokenCount';
|
|
7
|
-
import {
|
|
8
|
-
import { modelProviderSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
9
9
|
|
|
10
10
|
import { useStore } from '../store';
|
|
11
11
|
|
|
@@ -14,8 +14,8 @@ const Tokens = memo(() => {
|
|
|
14
14
|
const [systemRole, model] = useStore((s) => [s.config.systemRole, s.config.model]);
|
|
15
15
|
const systemTokenCount = useTokenCount(systemRole);
|
|
16
16
|
|
|
17
|
-
const showTag =
|
|
18
|
-
const modelMaxTokens =
|
|
17
|
+
const showTag = useUserStore(modelProviderSelectors.isModelHasMaxToken(model));
|
|
18
|
+
const modelMaxTokens = useUserStore(modelProviderSelectors.modelMaxToken(model));
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<Flexbox align={'center'} gap={8} horizontal>
|
|
@@ -8,8 +8,8 @@ import { memo, useEffect } from 'react';
|
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
|
-
import {
|
|
12
|
-
import { settingsSelectors } from '@/store/
|
|
11
|
+
import { useUserStore } from '@/store/user';
|
|
12
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
13
13
|
|
|
14
14
|
import { useStore } from '../store';
|
|
15
15
|
import SelectWithTTSPreview from './SelectWithTTSPreview';
|
|
@@ -22,7 +22,7 @@ const AgentTTS = memo(() => {
|
|
|
22
22
|
const { t } = useTranslation('setting');
|
|
23
23
|
const updateConfig = useStore((s) => s.setAgentConfig);
|
|
24
24
|
const [form] = AFrom.useForm();
|
|
25
|
-
const voiceList =
|
|
25
|
+
const voiceList = useUserStore((s) => {
|
|
26
26
|
const locale = settingsSelectors.currentLanguage(s);
|
|
27
27
|
return (all?: boolean) => new VoiceList(all ? undefined : locale);
|
|
28
28
|
});
|
|
@@ -4,8 +4,8 @@ import NextImage from 'next/image';
|
|
|
4
4
|
import { CSSProperties, memo, useCallback } from 'react';
|
|
5
5
|
|
|
6
6
|
import { DEFAULT_USER_AVATAR_URL } from '@/const/meta';
|
|
7
|
-
import {
|
|
8
|
-
import { commonSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { commonSelectors } from '@/store/user/selectors';
|
|
9
9
|
import { imageToBase64 } from '@/utils/imageToBase64';
|
|
10
10
|
import { createUploadImageHandler } from '@/utils/uploadFIle';
|
|
11
11
|
|
|
@@ -38,7 +38,7 @@ interface AvatarWithUploadProps {
|
|
|
38
38
|
const AvatarWithUpload = memo<AvatarWithUploadProps>(
|
|
39
39
|
({ size = 40, compressSize = 256, style, id }) => {
|
|
40
40
|
const { styles } = useStyle();
|
|
41
|
-
const [avatar, updateAvatar] =
|
|
41
|
+
const [avatar, updateAvatar] = useUserStore((s) => [
|
|
42
42
|
commonSelectors.userAvatar(s),
|
|
43
43
|
s.updateAvatar,
|
|
44
44
|
]);
|
|
@@ -9,8 +9,8 @@ import { Center } from 'react-layout-kit';
|
|
|
9
9
|
import { useAgentStore } from '@/store/agent';
|
|
10
10
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
11
11
|
import { useFileStore } from '@/store/file';
|
|
12
|
-
import {
|
|
13
|
-
import { modelProviderSelectors } from '@/store/
|
|
12
|
+
import { useUserStore } from '@/store/user';
|
|
13
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
14
14
|
|
|
15
15
|
const FileUpload = memo(() => {
|
|
16
16
|
const { t } = useTranslation('chat');
|
|
@@ -19,7 +19,7 @@ const FileUpload = memo(() => {
|
|
|
19
19
|
const upload = useFileStore((s) => s.uploadFile);
|
|
20
20
|
|
|
21
21
|
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
22
|
-
const [canUpload, enabledFiles] =
|
|
22
|
+
const [canUpload, enabledFiles] = useUserStore((s) => [
|
|
23
23
|
modelProviderSelectors.isModelEnabledUpload(model)(s),
|
|
24
24
|
modelProviderSelectors.isModelEnabledFiles(model)(s),
|
|
25
25
|
]);
|
|
@@ -9,10 +9,10 @@ import { useAgentStore } from '@/store/agent';
|
|
|
9
9
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
10
10
|
import { useChatStore } from '@/store/chat';
|
|
11
11
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
12
|
-
import { useGlobalStore } from '@/store/global';
|
|
13
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
14
12
|
import { useToolStore } from '@/store/tool';
|
|
15
13
|
import { toolSelectors } from '@/store/tool/selectors';
|
|
14
|
+
import { useUserStore } from '@/store/user';
|
|
15
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
16
16
|
|
|
17
17
|
const format = (number: number) => numeral(number).format('0,0');
|
|
18
18
|
|
|
@@ -29,10 +29,10 @@ const Token = memo(() => {
|
|
|
29
29
|
agentSelectors.currentAgentModel(s) as string,
|
|
30
30
|
]);
|
|
31
31
|
|
|
32
|
-
const maxTokens =
|
|
32
|
+
const maxTokens = useUserStore(modelProviderSelectors.modelMaxToken(model));
|
|
33
33
|
|
|
34
34
|
// Tool usage token
|
|
35
|
-
const canUseTool =
|
|
35
|
+
const canUseTool = useUserStore(modelProviderSelectors.isModelEnabledFunctionCall(model));
|
|
36
36
|
const plugins = useAgentStore(agentSelectors.currentAgentPlugins);
|
|
37
37
|
const toolsString = useToolStore((s) => {
|
|
38
38
|
const pluginSystemRoles = toolSelectors.enabledSystemRoles(plugins)(s);
|
|
@@ -3,14 +3,14 @@ import { memo } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { useAgentStore } from '@/store/agent';
|
|
5
5
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
6
|
-
import {
|
|
7
|
-
import { modelProviderSelectors } from '@/store/
|
|
6
|
+
import { useUserStore } from '@/store/user';
|
|
7
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
8
8
|
|
|
9
9
|
const LargeTokenContent = dynamic(() => import('./TokenTag'), { ssr: false });
|
|
10
10
|
|
|
11
11
|
const Token = memo(() => {
|
|
12
12
|
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
13
|
-
const showTag =
|
|
13
|
+
const showTag = useUserStore(modelProviderSelectors.isModelHasMaxToken(model));
|
|
14
14
|
|
|
15
15
|
return showTag && <LargeTokenContent />;
|
|
16
16
|
});
|
|
@@ -11,11 +11,11 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
11
11
|
import PluginStore from '@/features/PluginStore';
|
|
12
12
|
import { useAgentStore } from '@/store/agent';
|
|
13
13
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
14
|
-
import { useGlobalStore } from '@/store/global';
|
|
15
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
16
14
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
17
15
|
import { pluginHelpers, useToolStore } from '@/store/tool';
|
|
18
16
|
import { builtinToolSelectors, pluginSelectors } from '@/store/tool/selectors';
|
|
17
|
+
import { useUserStore } from '@/store/user';
|
|
18
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
19
19
|
|
|
20
20
|
import ToolItem from './ToolItem';
|
|
21
21
|
|
|
@@ -49,7 +49,7 @@ const Tools = memo(() => {
|
|
|
49
49
|
const { styles } = useStyles();
|
|
50
50
|
|
|
51
51
|
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
52
|
-
const enableFC =
|
|
52
|
+
const enableFC = useUserStore(modelProviderSelectors.isModelEnabledFunctionCall(model));
|
|
53
53
|
|
|
54
54
|
const items: ItemType[] = [
|
|
55
55
|
(builtinList.length !== 0 && {
|
|
@@ -7,8 +7,8 @@ import { SWRConfiguration } from 'swr';
|
|
|
7
7
|
import { useAgentStore } from '@/store/agent';
|
|
8
8
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
9
9
|
import { useChatStore } from '@/store/chat';
|
|
10
|
-
import {
|
|
11
|
-
import { settingsSelectors } from '@/store/
|
|
10
|
+
import { useUserStore } from '@/store/user';
|
|
11
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
12
12
|
import { ChatMessageError } from '@/types/message';
|
|
13
13
|
import { getMessageError } from '@/utils/fetch';
|
|
14
14
|
|
|
@@ -19,9 +19,9 @@ interface STTConfig extends SWRConfiguration {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const useBrowserSTT = (config: STTConfig) => {
|
|
22
|
-
const ttsSettings =
|
|
22
|
+
const ttsSettings = useUserStore(settingsSelectors.currentTTS, isEqual);
|
|
23
23
|
const ttsAgentSettings = useAgentStore(agentSelectors.currentAgentTTS, isEqual);
|
|
24
|
-
const locale =
|
|
24
|
+
const locale = useUserStore(settingsSelectors.currentLanguage);
|
|
25
25
|
|
|
26
26
|
const autoStop = ttsSettings.sttAutoStop;
|
|
27
27
|
const sttLocale =
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { settingsSelectors } from '@/store/
|
|
4
|
+
import { useUserStore } from '@/store/user';
|
|
5
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
6
6
|
|
|
7
7
|
import BrowserSTT from './browser';
|
|
8
8
|
import OpenaiSTT from './openai';
|
|
9
9
|
|
|
10
10
|
const STT = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
11
|
-
const { sttServer } =
|
|
11
|
+
const { sttServer } = useUserStore(settingsSelectors.currentTTS, isEqual);
|
|
12
12
|
switch (sttServer) {
|
|
13
13
|
case 'openai': {
|
|
14
14
|
return <OpenaiSTT mobile={mobile} />;
|
|
@@ -10,8 +10,8 @@ import { API_ENDPOINTS } from '@/services/_url';
|
|
|
10
10
|
import { useAgentStore } from '@/store/agent';
|
|
11
11
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
12
12
|
import { useChatStore } from '@/store/chat';
|
|
13
|
-
import {
|
|
14
|
-
import { settingsSelectors } from '@/store/
|
|
13
|
+
import { useUserStore } from '@/store/user';
|
|
14
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
15
15
|
import { ChatMessageError } from '@/types/message';
|
|
16
16
|
import { getMessageError } from '@/utils/fetch';
|
|
17
17
|
|
|
@@ -22,9 +22,9 @@ interface STTConfig extends SWRConfiguration {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const useOpenaiSTT = (config: STTConfig) => {
|
|
25
|
-
const ttsSettings =
|
|
25
|
+
const ttsSettings = useUserStore(settingsSelectors.currentTTS, isEqual);
|
|
26
26
|
const ttsAgentSettings = useAgentStore(agentSelectors.currentAgentTTS, isEqual);
|
|
27
|
-
const locale =
|
|
27
|
+
const locale = useUserStore(settingsSelectors.currentLanguage);
|
|
28
28
|
|
|
29
29
|
const autoStop = ttsSettings.sttAutoStop;
|
|
30
30
|
const sttLocale =
|
|
@@ -4,8 +4,8 @@ import { useCallback, useRef, useState } from 'react';
|
|
|
4
4
|
import { useAgentStore } from '@/store/agent';
|
|
5
5
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
6
6
|
import { useChatStore } from '@/store/chat';
|
|
7
|
-
import {
|
|
8
|
-
import { modelProviderSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
9
9
|
|
|
10
10
|
import { useSendMessage } from './useSend';
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ export const useChatInput = () => {
|
|
|
15
15
|
const onSend = useSendMessage();
|
|
16
16
|
|
|
17
17
|
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
18
|
-
const canUpload =
|
|
18
|
+
const canUpload = useUserStore(modelProviderSelectors.isModelEnabledUpload(model));
|
|
19
19
|
|
|
20
20
|
const [loading, value, onInput, onStop] = useChatStore((s) => [
|
|
21
21
|
!!s.chatLoadingId,
|
|
@@ -7,8 +7,8 @@ import { memo, useState } from 'react';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
|
|
9
9
|
import { ModelProvider } from '@/libs/agent-runtime';
|
|
10
|
-
import {
|
|
11
|
-
import { modelConfigSelectors } from '@/store/
|
|
10
|
+
import { useUserStore } from '@/store/user';
|
|
11
|
+
import { modelConfigSelectors } from '@/store/user/selectors';
|
|
12
12
|
|
|
13
13
|
import { FormAction } from '../style';
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ const BedrockForm = memo(() => {
|
|
|
16
16
|
const { t } = useTranslation('modelProvider');
|
|
17
17
|
const [showRegion, setShow] = useState(false);
|
|
18
18
|
|
|
19
|
-
const [accessKeyId, secretAccessKey, region, setConfig] =
|
|
19
|
+
const [accessKeyId, secretAccessKey, region, setConfig] = useUserStore((s) => [
|
|
20
20
|
modelConfigSelectors.bedrockConfig(s).accessKeyId,
|
|
21
21
|
modelConfigSelectors.bedrockConfig(s).secretAccessKey,
|
|
22
22
|
modelConfigSelectors.bedrockConfig(s).region,
|
|
@@ -4,8 +4,8 @@ import { Network } from 'lucide-react';
|
|
|
4
4
|
import { ReactNode, memo, useState } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { settingsSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
9
9
|
import { GlobalLLMProviderKey } from '@/types/settings';
|
|
10
10
|
|
|
11
11
|
import { FormAction } from '../style';
|
|
@@ -23,7 +23,7 @@ const ProviderApiKeyForm = memo<ProviderApiKeyFormProps>(
|
|
|
23
23
|
const { t: errorT } = useTranslation('error');
|
|
24
24
|
const [showProxy, setShow] = useState(false);
|
|
25
25
|
|
|
26
|
-
const [apiKey, proxyUrl, setConfig] =
|
|
26
|
+
const [apiKey, proxyUrl, setConfig] = useUserStore((s) => [
|
|
27
27
|
settingsSelectors.providerConfig(provider)(s)?.apiKey,
|
|
28
28
|
settingsSelectors.providerConfig(provider)(s)?.endpoint,
|
|
29
29
|
s.setModelProviderConfig,
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Anthropic,
|
|
3
3
|
Google,
|
|
4
4
|
Groq,
|
|
5
|
+
Minimax,
|
|
5
6
|
Mistral,
|
|
6
7
|
Moonshot,
|
|
7
8
|
OpenAI,
|
|
@@ -32,6 +33,10 @@ const ProviderAvatar = memo<ProviderAvatarProps>(({ provider }) => {
|
|
|
32
33
|
return <Zhipu.Color size={64} />;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
case ModelProvider.Minimax: {
|
|
37
|
+
return <Minimax.Color size={56} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
case ModelProvider.Mistral: {
|
|
36
41
|
return <Mistral.Color size={56} />;
|
|
37
42
|
}
|
|
@@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
|
5
5
|
|
|
6
6
|
import { useChatStore } from '@/store/chat';
|
|
7
|
-
import {
|
|
8
|
-
import { settingsSelectors } from '@/store/
|
|
7
|
+
import { useUserStore } from '@/store/user';
|
|
8
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
9
9
|
|
|
10
10
|
import { FormAction } from './style';
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ interface AccessCodeFormProps {
|
|
|
15
15
|
|
|
16
16
|
const AccessCodeForm = memo<AccessCodeFormProps>(({ id }) => {
|
|
17
17
|
const { t } = useTranslation('error');
|
|
18
|
-
const [password, setSettings] =
|
|
18
|
+
const [password, setSettings] = useUserStore((s) => [
|
|
19
19
|
settingsSelectors.currentSettings(s).password,
|
|
20
20
|
s.setSettings,
|
|
21
21
|
]);
|
|
@@ -69,6 +69,7 @@ const ErrorMessageExtra = memo<{ data: ChatMessage }>(({ data }) => {
|
|
|
69
69
|
|
|
70
70
|
case AgentRuntimeErrorType.InvalidBedrockCredentials:
|
|
71
71
|
case AgentRuntimeErrorType.InvalidZhipuAPIKey:
|
|
72
|
+
case AgentRuntimeErrorType.InvalidMinimaxAPIKey:
|
|
72
73
|
case AgentRuntimeErrorType.InvalidMistralAPIKey:
|
|
73
74
|
case AgentRuntimeErrorType.InvalidMoonshotAPIKey:
|
|
74
75
|
case AgentRuntimeErrorType.InvalidGoogleAPIKey:
|
|
@@ -3,8 +3,8 @@ import { Md5 } from 'ts-md5';
|
|
|
3
3
|
|
|
4
4
|
import { useAgentStore } from '@/store/agent';
|
|
5
5
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
6
|
-
import {
|
|
7
|
-
import { settingsSelectors } from '@/store/
|
|
6
|
+
import { useUserStore } from '@/store/user';
|
|
7
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
8
8
|
|
|
9
9
|
import FilePlayer from './FilePlayer';
|
|
10
10
|
import InitPlayer, { TTSProps } from './InitPlayer';
|
|
@@ -12,7 +12,7 @@ import InitPlayer, { TTSProps } from './InitPlayer';
|
|
|
12
12
|
const TTS = memo<TTSProps>(
|
|
13
13
|
(props) => {
|
|
14
14
|
const { file, voice, content, contentMd5 } = props;
|
|
15
|
-
const lang =
|
|
15
|
+
const lang = useUserStore(settingsSelectors.currentLanguage);
|
|
16
16
|
const currentVoice = useAgentStore(agentSelectors.currentAgentTTSVoice(lang));
|
|
17
17
|
|
|
18
18
|
const md5 = useMemo(() => Md5.hashStr(content).toString(), [content]);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Markdown } from '@lobehub/ui';
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { settingsSelectors } from '@/store/
|
|
4
|
+
import { useUserStore } from '@/store/user';
|
|
5
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
6
6
|
|
|
7
7
|
import Loading from '../Loading';
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ export interface PluginMarkdownTypeProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const PluginMarkdownType = memo<PluginMarkdownTypeProps>(({ content, loading }) => {
|
|
15
|
-
const fontSize =
|
|
15
|
+
const fontSize = useUserStore((s) => settingsSelectors.currentSettings(s).fontSize);
|
|
16
16
|
if (loading) return <Loading />;
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -8,10 +8,10 @@ import { useAgentStore } from '@/store/agent';
|
|
|
8
8
|
import { agentSelectors } from '@/store/agent/selectors';
|
|
9
9
|
import { useChatStore } from '@/store/chat';
|
|
10
10
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
11
|
-
import { useGlobalStore } from '@/store/global';
|
|
12
|
-
import { settingsSelectors } from '@/store/global/selectors';
|
|
13
11
|
import { useSessionStore } from '@/store/session';
|
|
14
12
|
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
13
|
+
import { useUserStore } from '@/store/user';
|
|
14
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
15
15
|
import { ChatMessage } from '@/types/message';
|
|
16
16
|
|
|
17
17
|
import ErrorMessageExtra, { getErrorAlertConfig } from '../../Error';
|
|
@@ -38,7 +38,7 @@ export interface ChatListItemProps {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const Item = memo<ChatListItemProps>(({ index, id }) => {
|
|
41
|
-
const fontSize =
|
|
41
|
+
const fontSize = useUserStore((s) => settingsSelectors.currentSettings(s).fontSize);
|
|
42
42
|
const { t } = useTranslation('common');
|
|
43
43
|
const { styles, cx } = useStyles();
|
|
44
44
|
const [editing, setEditing] = useState(false);
|
|
@@ -11,8 +11,8 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
11
11
|
import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
|
|
12
12
|
import { useAgentStore } from '@/store/agent';
|
|
13
13
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
|
14
|
-
import {
|
|
15
|
-
import { modelProviderSelectors } from '@/store/
|
|
14
|
+
import { useUserStore } from '@/store/user';
|
|
15
|
+
import { modelProviderSelectors } from '@/store/user/selectors';
|
|
16
16
|
import { ModelProviderCard } from '@/types/llm';
|
|
17
17
|
import { withBasePath } from '@/utils/basePath';
|
|
18
18
|
|
|
@@ -46,10 +46,7 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
|
|
|
46
46
|
]);
|
|
47
47
|
|
|
48
48
|
const router = useRouter();
|
|
49
|
-
const enabledList =
|
|
50
|
-
modelProviderSelectors.modelProviderListForModelSelect,
|
|
51
|
-
isEqual,
|
|
52
|
-
);
|
|
49
|
+
const enabledList = useUserStore(modelProviderSelectors.modelProviderListForModelSelect, isEqual);
|
|
53
50
|
|
|
54
51
|
const items = useMemo(() => {
|
|
55
52
|
const getModelItems = (provider: ModelProviderCard) => {
|
|
@@ -4,16 +4,16 @@ import dynamic from 'next/dynamic';
|
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
|
-
import { useGlobalStore } from '@/store/global';
|
|
8
|
-
import { settingsSelectors } from '@/store/global/selectors';
|
|
9
7
|
import { useToolStore } from '@/store/tool';
|
|
10
8
|
import { pluginSelectors } from '@/store/tool/selectors';
|
|
9
|
+
import { useUserStore } from '@/store/user';
|
|
10
|
+
import { settingsSelectors } from '@/store/user/selectors';
|
|
11
11
|
|
|
12
12
|
const EmojiPicker = dynamic(() => import('@lobehub/ui/es/EmojiPicker'), { ssr: false });
|
|
13
13
|
|
|
14
14
|
const LocalForm = memo<{ form: FormInstance; mode?: 'edit' | 'create' }>(({ form, mode }) => {
|
|
15
15
|
const isEditMode = mode === 'edit';
|
|
16
|
-
const locale =
|
|
16
|
+
const locale = useUserStore(settingsSelectors.currentLanguage);
|
|
17
17
|
const { t } = useTranslation('plugin');
|
|
18
18
|
|
|
19
19
|
const pluginIds = useToolStore(pluginSelectors.storeAndInstallPluginsIdList);
|
|
@@ -7,8 +7,8 @@ import { memo } from 'react';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import { syncSettingsSelectors } from '@/store/
|
|
10
|
+
import { useUserStore } from '@/store/user';
|
|
11
|
+
import { syncSettingsSelectors } from '@/store/user/selectors';
|
|
12
12
|
|
|
13
13
|
interface DisableSyncProps {
|
|
14
14
|
noPopover?: boolean;
|
|
@@ -17,7 +17,7 @@ interface DisableSyncProps {
|
|
|
17
17
|
|
|
18
18
|
const DisableSync = memo<DisableSyncProps>(({ noPopover, placement = 'bottomLeft' }) => {
|
|
19
19
|
const { t } = useTranslation('common');
|
|
20
|
-
const [haveConfig, setSettings] =
|
|
20
|
+
const [haveConfig, setSettings] = useUserStore((s) => [
|
|
21
21
|
!!syncSettingsSelectors.webrtcConfig(s).channelName,
|
|
22
22
|
s.setSettings,
|
|
23
23
|
]);
|
|
@@ -9,8 +9,8 @@ import { memo } from 'react';
|
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
10
|
import { Flexbox } from 'react-layout-kit';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import { syncSettingsSelectors } from '@/store/
|
|
12
|
+
import { useUserStore } from '@/store/user';
|
|
13
|
+
import { syncSettingsSelectors } from '@/store/user/selectors';
|
|
14
14
|
import { pathString } from '@/utils/url';
|
|
15
15
|
|
|
16
16
|
import EnableTag from './EnableTag';
|
|
@@ -39,7 +39,7 @@ const EnableSync = memo<EnableSyncProps>(({ hiddenActions, placement = 'bottomLe
|
|
|
39
39
|
const { t } = useTranslation('common');
|
|
40
40
|
|
|
41
41
|
const { styles, theme } = useStyles();
|
|
42
|
-
const [syncStatus, isSyncing, channelName, enableWebRTC, setSettings] =
|
|
42
|
+
const [syncStatus, isSyncing, channelName, enableWebRTC, setSettings] = useUserStore((s) => [
|
|
43
43
|
s.syncStatus,
|
|
44
44
|
s.syncStatus === 'syncing',
|
|
45
45
|
syncSettingsSelectors.webrtcChannelName(s),
|
|
@@ -47,7 +47,7 @@ const EnableSync = memo<EnableSyncProps>(({ hiddenActions, placement = 'bottomLe
|
|
|
47
47
|
s.setSettings,
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
|
-
const users =
|
|
50
|
+
const users = useUserStore((s) => s.syncAwareness, isEqual);
|
|
51
51
|
|
|
52
52
|
const switchSync = (enabled: boolean) => {
|
|
53
53
|
setSettings({ sync: { webrtc: { enabled } } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TooltipPlacement } from 'antd/es/tooltip';
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useUserStore } from '@/store/user';
|
|
5
5
|
|
|
6
6
|
import DisableSync from './DisableSync';
|
|
7
7
|
import EnableSync from './EnableSync';
|
|
@@ -14,7 +14,7 @@ interface SyncStatusTagProps {
|
|
|
14
14
|
|
|
15
15
|
const SyncStatusTag = memo<SyncStatusTagProps>(
|
|
16
16
|
({ hiddenActions, placement, hiddenEnableGuide }) => {
|
|
17
|
-
const [enableSync] =
|
|
17
|
+
const [enableSync] = useUserStore((s) => [s.syncEnabled]);
|
|
18
18
|
|
|
19
19
|
return enableSync ? (
|
|
20
20
|
<EnableSync hiddenActions={hiddenActions} placement={placement} />
|