@lobehub/chat 0.82.9 → 0.83.1
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/CHANGELOG.md +50 -0
- package/locales/en_US/error.json +2 -1
- package/locales/en_US/plugin.json +1 -0
- package/locales/en_US/setting.json +2 -1
- package/locales/ru_RU/error.json +2 -1
- package/locales/ru_RU/plugin.json +1 -0
- package/locales/ru_RU/setting.json +2 -1
- package/locales/zh_CN/error.json +1 -0
- package/locales/zh_CN/plugin.json +2 -1
- package/locales/zh_CN/setting.json +2 -1
- package/locales/zh_TW/error.json +2 -1
- package/locales/zh_TW/plugin.json +1 -0
- package/locales/zh_TW/setting.json +2 -1
- package/package.json +6 -5
- package/src/app/chat/components/SessionList/List/Item/index.tsx +2 -2
- package/src/app/home/index.tsx +15 -11
- package/src/app/layout.tsx +4 -1
- package/src/app/settings/agent/Agent.tsx +3 -3
- package/src/app/settings/agent/page.tsx +19 -5
- package/src/app/settings/common/Common.tsx +109 -117
- package/src/app/settings/common/page.tsx +18 -5
- package/src/app/settings/features/SideBar/List.tsx +11 -5
- package/src/app/settings/llm/LLM/index.tsx +2 -2
- package/src/app/settings/llm/page.tsx +18 -5
- package/src/config/client.ts +13 -0
- package/src/const/locale.ts +9 -0
- package/src/const/settings.ts +1 -1
- package/src/const/url.ts +1 -6
- package/src/helpers/export.ts +2 -2
- package/src/layout/GlobalLayout/Locale.tsx +44 -0
- package/src/layout/GlobalLayout/LocaleLoading.tsx +21 -0
- package/src/layout/GlobalLayout/StoreHydration.tsx +28 -0
- package/src/layout/GlobalLayout/index.tsx +29 -41
- package/src/locales/create.ts +43 -26
- package/src/locales/default/setting.ts +2 -1
- package/src/locales/options.ts +6 -5
- package/src/services/agentMarket.ts +6 -4
- package/src/services/pluginMarket.ts +2 -2
- package/src/store/global/hooks/useSwitchSettingsOnInit.ts +5 -2
- package/src/store/global/{selectors.test.ts → selectors/settings.test.ts} +11 -11
- package/src/store/global/selectors/settings.ts +44 -0
- package/src/store/global/selectors.ts +1 -36
- package/src/store/global/slices/common.ts +3 -4
- package/src/types/locale.ts +4 -0
- package/src/types/settings.ts +2 -2
- package/src/utils/env.ts +2 -0
- package/src/utils/responsive.ts +1 -1
- package/src/utils/switchLang.ts +5 -1
- package/src/app/settings/agent/index.tsx +0 -20
- package/src/app/settings/common/index.tsx +0 -20
- package/src/app/settings/llm/index.tsx +0 -20
- package/src/layout/GlobalLayout/style.ts +0 -18
- /package/src/{components/AppTheme/index.tsx → layout/GlobalLayout/AppTheme.tsx} +0 -0
|
@@ -1,36 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { DEFAULT_AGENT, DEFAULT_AGENT_CONFIG, DEFAULT_SETTINGS } from '@/const/settings';
|
|
3
|
-
import { GlobalSettings } from '@/types/settings';
|
|
4
|
-
import { merge } from '@/utils/merge';
|
|
5
|
-
|
|
6
|
-
import { GlobalStore } from './store';
|
|
7
|
-
|
|
8
|
-
const currentSettings = (s: GlobalStore) => merge(DEFAULT_SETTINGS, s.settings);
|
|
9
|
-
|
|
10
|
-
const defaultAgent = (s: GlobalStore) => merge(DEFAULT_AGENT, s.settings.defaultAgent);
|
|
11
|
-
|
|
12
|
-
const defaultAgentConfig = (s: GlobalStore) => merge(DEFAULT_AGENT_CONFIG, defaultAgent(s).config);
|
|
13
|
-
|
|
14
|
-
const defaultAgentMeta = (s: GlobalStore) => merge(DEFAULT_AGENT_META, defaultAgent(s).meta);
|
|
15
|
-
|
|
16
|
-
const openAIAPIKeySelectors = (s: GlobalStore) =>
|
|
17
|
-
s.settings.languageModel.openAI.OPENAI_API_KEY || s.settings.OPENAI_API_KEY;
|
|
18
|
-
|
|
19
|
-
export const exportSettings = (s: GlobalStore) => {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
-
const { OPENAI_API_KEY: _, password: __, ...settings } = s.settings;
|
|
22
|
-
|
|
23
|
-
return settings as GlobalSettings;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const globalSelectors = {
|
|
27
|
-
currentSettings,
|
|
28
|
-
defaultAgent,
|
|
29
|
-
defaultAgentConfig,
|
|
30
|
-
defaultAgentMeta,
|
|
31
|
-
exportSettings,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const settingsSelectors = {
|
|
35
|
-
openAIAPI: openAIAPIKeySelectors,
|
|
36
|
-
};
|
|
1
|
+
export * from './selectors/settings';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
|
-
import { merge } from 'lodash-es';
|
|
3
2
|
import type { StateCreator } from 'zustand/vanilla';
|
|
4
3
|
|
|
4
|
+
import { merge } from '@/utils/merge';
|
|
5
5
|
import { setNamespace } from '@/utils/storeDebug';
|
|
6
6
|
|
|
7
7
|
import type { GlobalPreference, GlobalState, Guide, SidebarTabKey } from '../initialState';
|
|
@@ -47,14 +47,13 @@ export const createCommonSlice: StateCreator<
|
|
|
47
47
|
},
|
|
48
48
|
updateGuideState: (guide) => {
|
|
49
49
|
const { updatePreference } = get();
|
|
50
|
-
const nextGuide = merge(
|
|
50
|
+
const nextGuide = merge(get().preference.guide, guide);
|
|
51
51
|
updatePreference({ guide: nextGuide });
|
|
52
52
|
},
|
|
53
|
-
|
|
54
53
|
updatePreference: (preference, action) => {
|
|
55
54
|
set(
|
|
56
55
|
produce((draft: GlobalState) => {
|
|
57
|
-
draft.preference = merge(
|
|
56
|
+
draft.preference = merge(draft.preference, preference);
|
|
58
57
|
}),
|
|
59
58
|
false,
|
|
60
59
|
action,
|
package/src/types/locale.ts
CHANGED
package/src/types/settings.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NeutralColors, PrimaryColors } from '@lobehub/ui';
|
|
2
2
|
import type { ThemeMode } from 'antd-style';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { LocaleMode } from '@/types/locale';
|
|
5
5
|
import type { LobeAgentSession } from '@/types/session';
|
|
6
6
|
|
|
7
7
|
export interface GlobalBaseSettings {
|
|
@@ -36,7 +36,7 @@ export interface GlobalBaseSettings {
|
|
|
36
36
|
* @deprecated
|
|
37
37
|
*/
|
|
38
38
|
historyCount?: number;
|
|
39
|
-
language:
|
|
39
|
+
language: LocaleMode;
|
|
40
40
|
neutralColor?: NeutralColors;
|
|
41
41
|
password: string;
|
|
42
42
|
primaryColor?: PrimaryColors;
|
package/src/utils/env.ts
CHANGED
package/src/utils/responsive.ts
CHANGED
package/src/utils/switchLang.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { changeLanguage } from 'i18next';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { LocaleMode } from '@/types/locale';
|
|
4
|
+
|
|
5
|
+
export const switchLang = (locale: LocaleMode) => {
|
|
6
|
+
const lang = locale === 'auto' ? navigator.language : locale;
|
|
7
|
+
|
|
4
8
|
changeLanguage(lang);
|
|
5
9
|
document.documentElement.lang = lang;
|
|
6
10
|
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
|
|
6
|
-
import { SettingsTabs } from '@/store/global/initialState';
|
|
7
|
-
|
|
8
|
-
import Layout from '../index';
|
|
9
|
-
import Agent from './Agent';
|
|
10
|
-
|
|
11
|
-
const AgentSetting = memo(() => {
|
|
12
|
-
useSwitchSideBarOnInit(SettingsTabs.Agent);
|
|
13
|
-
return (
|
|
14
|
-
<Layout>
|
|
15
|
-
<Agent />
|
|
16
|
-
</Layout>
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default AgentSetting;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
|
|
6
|
-
import { SettingsTabs } from '@/store/global/initialState';
|
|
7
|
-
|
|
8
|
-
import Layout from '../index';
|
|
9
|
-
import Common from './Common';
|
|
10
|
-
|
|
11
|
-
const CommonSetting = memo(() => {
|
|
12
|
-
useSwitchSideBarOnInit(SettingsTabs.Common);
|
|
13
|
-
return (
|
|
14
|
-
<Layout>
|
|
15
|
-
<Common />
|
|
16
|
-
</Layout>
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default CommonSetting;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
|
|
6
|
-
import { SettingsTabs } from '@/store/global/initialState';
|
|
7
|
-
|
|
8
|
-
import Layout from '../index';
|
|
9
|
-
import LLM from './LLM';
|
|
10
|
-
|
|
11
|
-
const LLMSetting = memo(() => {
|
|
12
|
-
useSwitchSideBarOnInit(SettingsTabs.LLM);
|
|
13
|
-
return (
|
|
14
|
-
<Layout>
|
|
15
|
-
<LLM />
|
|
16
|
-
</Layout>
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default LLMSetting;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createStyles } from 'antd-style';
|
|
2
|
-
|
|
3
|
-
export const useStyles = createStyles(({ css, token }) => ({
|
|
4
|
-
bg: css`
|
|
5
|
-
overflow-y: scroll;
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
align-items: center;
|
|
9
|
-
|
|
10
|
-
height: 100%;
|
|
11
|
-
|
|
12
|
-
background: ${token.colorBgLayout};
|
|
13
|
-
|
|
14
|
-
:has(#ChatLayout, #FlowLayout) {
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
}
|
|
17
|
-
`,
|
|
18
|
-
}));
|
|
File without changes
|