@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.
Files changed (53) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/locales/en_US/error.json +2 -1
  3. package/locales/en_US/plugin.json +1 -0
  4. package/locales/en_US/setting.json +2 -1
  5. package/locales/ru_RU/error.json +2 -1
  6. package/locales/ru_RU/plugin.json +1 -0
  7. package/locales/ru_RU/setting.json +2 -1
  8. package/locales/zh_CN/error.json +1 -0
  9. package/locales/zh_CN/plugin.json +2 -1
  10. package/locales/zh_CN/setting.json +2 -1
  11. package/locales/zh_TW/error.json +2 -1
  12. package/locales/zh_TW/plugin.json +1 -0
  13. package/locales/zh_TW/setting.json +2 -1
  14. package/package.json +6 -5
  15. package/src/app/chat/components/SessionList/List/Item/index.tsx +2 -2
  16. package/src/app/home/index.tsx +15 -11
  17. package/src/app/layout.tsx +4 -1
  18. package/src/app/settings/agent/Agent.tsx +3 -3
  19. package/src/app/settings/agent/page.tsx +19 -5
  20. package/src/app/settings/common/Common.tsx +109 -117
  21. package/src/app/settings/common/page.tsx +18 -5
  22. package/src/app/settings/features/SideBar/List.tsx +11 -5
  23. package/src/app/settings/llm/LLM/index.tsx +2 -2
  24. package/src/app/settings/llm/page.tsx +18 -5
  25. package/src/config/client.ts +13 -0
  26. package/src/const/locale.ts +9 -0
  27. package/src/const/settings.ts +1 -1
  28. package/src/const/url.ts +1 -6
  29. package/src/helpers/export.ts +2 -2
  30. package/src/layout/GlobalLayout/Locale.tsx +44 -0
  31. package/src/layout/GlobalLayout/LocaleLoading.tsx +21 -0
  32. package/src/layout/GlobalLayout/StoreHydration.tsx +28 -0
  33. package/src/layout/GlobalLayout/index.tsx +29 -41
  34. package/src/locales/create.ts +43 -26
  35. package/src/locales/default/setting.ts +2 -1
  36. package/src/locales/options.ts +6 -5
  37. package/src/services/agentMarket.ts +6 -4
  38. package/src/services/pluginMarket.ts +2 -2
  39. package/src/store/global/hooks/useSwitchSettingsOnInit.ts +5 -2
  40. package/src/store/global/{selectors.test.ts → selectors/settings.test.ts} +11 -11
  41. package/src/store/global/selectors/settings.ts +44 -0
  42. package/src/store/global/selectors.ts +1 -36
  43. package/src/store/global/slices/common.ts +3 -4
  44. package/src/types/locale.ts +4 -0
  45. package/src/types/settings.ts +2 -2
  46. package/src/utils/env.ts +2 -0
  47. package/src/utils/responsive.ts +1 -1
  48. package/src/utils/switchLang.ts +5 -1
  49. package/src/app/settings/agent/index.tsx +0 -20
  50. package/src/app/settings/common/index.tsx +0 -20
  51. package/src/app/settings/llm/index.tsx +0 -20
  52. package/src/layout/GlobalLayout/style.ts +0 -18
  53. /package/src/{components/AppTheme/index.tsx → layout/GlobalLayout/AppTheme.tsx} +0 -0
@@ -1,36 +1 @@
1
- import { DEFAULT_AGENT_META } from '@/const/meta';
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({}, get().preference.guide, guide);
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({}, draft.preference, preference);
56
+ draft.preference = merge(draft.preference, preference);
58
57
  }),
59
58
  false,
60
59
  action,
@@ -1 +1,5 @@
1
+ import { Locales } from '@/locales/resources';
2
+
1
3
  export type * from '@/locales/resources';
4
+
5
+ export type LocaleMode = Locales | 'auto';
@@ -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 type { Locales } from '@/locales/resources';
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: Locales;
39
+ language: LocaleMode;
40
40
  neutralColor?: NeutralColors;
41
41
  password: string;
42
42
  primaryColor?: PrimaryColors;
package/src/utils/env.ts CHANGED
@@ -1 +1,3 @@
1
1
  export const isDev = process.env.NODE_ENV === 'development';
2
+
3
+ export const isOnServerSide = typeof window === 'undefined';
@@ -12,7 +12,7 @@ export const isMobileDevice = () => {
12
12
  const { get } = headers();
13
13
  const ua = get('user-agent');
14
14
 
15
- console.log(ua);
15
+ // console.log(ua);
16
16
  const device = new UAParser(ua || '').getDevice();
17
17
 
18
18
  return device.type === 'mobile';
@@ -1,6 +1,10 @@
1
1
  import { changeLanguage } from 'i18next';
2
2
 
3
- export const switchLang = (lang: string) => {
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
- }));