@lobehub/chat 0.79.7 → 0.80.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/package.json +1 -1
  3. package/public/icons/icon-192x192.png +0 -0
  4. package/public/icons/icon-512x512.png +0 -0
  5. package/public/icons/icon-maskable-192x192.png +0 -0
  6. package/public/icons/icon-maskable-512x512.png +0 -0
  7. package/public/manifest.json +21 -6
  8. package/src/app/chat/features/Conversation/ChatList/index.tsx +18 -4
  9. package/src/app/chat/features/Conversation/Input/ActionBar/ActionRight.tsx +21 -15
  10. package/src/app/chat/features/Conversation/Input/Mobile.tsx +24 -1
  11. package/src/app/chat/index.tsx +1 -1
  12. package/src/app/chat/settings/index.tsx +1 -1
  13. package/src/app/chat/settings/{layout.pc.tsx → layout.desktop.tsx} +1 -1
  14. package/src/app/market/features/SideBar/AgentInfo/style.ts +4 -4
  15. package/src/app/market/index.tsx +1 -1
  16. package/src/app/metadata.ts +5 -16
  17. package/src/app/settings/features/Banner/index.tsx +2 -3
  18. package/src/app/settings/features/Settings/Common.tsx +2 -9
  19. package/src/app/settings/index.tsx +1 -1
  20. package/src/app/welcome/index.tsx +1 -1
  21. package/src/app/welcome/layout.mobile.tsx +1 -1
  22. package/src/const/layoutTokens.ts +1 -0
  23. package/src/const/settings.ts +1 -1
  24. package/src/features/AgentSetting/AgentPlugin/MarketList.tsx +2 -2
  25. package/src/hooks/useIsPWA.ts +1 -2
  26. package/src/layout/GlobalLayout/index.tsx +2 -4
  27. package/src/locales/create.ts +17 -25
  28. package/src/styles/antdOverride.ts +5 -7
  29. package/src/styles/global.ts +2 -2
  30. package/src/styles/index.ts +6 -1
  31. package/src/utils/switchLang.ts +6 -0
  32. /package/src/app/chat/{layout.pc.tsx → layout.desktop.tsx} +0 -0
  33. /package/src/app/market/{layout.pc.tsx → layout.desktop.tsx} +0 -0
  34. /package/src/app/settings/{layout.pc.tsx → layout.desktop.tsx} +0 -0
  35. /package/src/app/welcome/{layout.pc.tsx → layout.desktop.tsx} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.80.0](https://github.com/lobehub/lobe-chat/compare/v0.79.8...v0.80.0)
6
+
7
+ <sup>Released on **2023-09-27**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Improve user experience and ensure consistency.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: Improve user experience and ensure consistency ([abba584](https://github.com/lobehub/lobe-chat/commit/abba584))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.79.8](https://github.com/lobehub/lobe-chat/compare/v0.79.7...v0.79.8)
31
+
32
+ <sup>Released on **2023-09-27**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Fix safeare in mobile.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Fix safeare in mobile ([2adfb04](https://github.com/lobehub/lobe-chat/commit/2adfb04))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 0.79.7](https://github.com/lobehub/lobe-chat/compare/v0.79.6...v0.79.7)
6
56
 
7
57
  <sup>Released on **2023-09-27**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.79.7",
3
+ "version": "0.80.0",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
Binary file
Binary file
@@ -4,23 +4,38 @@
4
4
  "display": "fullscreen",
5
5
  "icons": [
6
6
  {
7
- "src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/android-chrome-192x192.png",
7
+ "src": "/icons/icon-192x192.png",
8
8
  "sizes": "192x192",
9
- "type": "image/png"
9
+ "type": "image/png",
10
+ "purpose": "any"
11
+ },
12
+ {
13
+ "src": "/icons/icon-maskable-192x192.png",
14
+ "sizes": "192x192",
15
+ "type": "image/png",
16
+ "purpose": "maskable"
10
17
  },
11
18
  {
12
- "src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/android-chrome-512x512.png",
19
+ "src": "/icons/icon-512x512.png",
13
20
  "sizes": "512x512",
14
- "type": "image/png"
21
+ "type": "image/png",
22
+ "purpose": "any"
23
+ },
24
+ {
25
+ "src": "/icons/icon-maskable-512x512.png",
26
+ "sizes": "512x512",
27
+ "type": "image/png",
28
+ "purpose": "maskable"
15
29
  }
16
30
  ],
31
+ "id": "/",
17
32
  "name": "LobeChat",
18
33
  "orientation": "portrait",
19
34
  "scope": "/",
20
35
  "screenshots": [
21
36
  {
22
- "src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-960x720.png",
23
- "sizes": "960x720",
37
+ "src": "https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-960x540.png",
38
+ "sizes": "960x540",
24
39
  "type": "image/png"
25
40
  }
26
41
  ],
@@ -1,4 +1,5 @@
1
1
  import { ChatList, RenderMessage } from '@lobehub/ui';
2
+ import { createStyles } from 'antd-style';
2
3
  import isEqual from 'fast-deep-equal';
3
4
  import { memo, useCallback } from 'react';
4
5
  import { useTranslation } from 'react-i18next';
@@ -15,10 +16,22 @@ import FunctionCall from './Plugins/FunctionCall';
15
16
  import PluginMessage from './Plugins/PluginMessage';
16
17
  import SkeletonList from './SkeletonList';
17
18
 
18
- const List = () => {
19
+ const useStyles = createStyles(({ css, responsive, cx, stylish }) =>
20
+ cx(
21
+ stylish.noScrollbar,
22
+ css`
23
+ overflow-x: hidden;
24
+ ${responsive.mobile} {
25
+ width: 100vw;
26
+ }
27
+ `,
28
+ ),
29
+ );
30
+
31
+ const List = memo(() => {
19
32
  const init = useSessionChatInit();
20
33
  const { t } = useTranslation('common');
21
-
34
+ const { styles } = useStyles();
22
35
  const data = useSessionStore(chatSelectors.currentChatsWithGuideMessage, isEqual);
23
36
 
24
37
  const [
@@ -83,6 +96,7 @@ const List = () => {
83
96
 
84
97
  return (
85
98
  <ChatList
99
+ className={styles}
86
100
  data={data}
87
101
  enableHistoryCount={enableHistoryCount}
88
102
  historyCount={historyCount}
@@ -120,6 +134,6 @@ const List = () => {
120
134
  type={displayMode || 'chat'}
121
135
  />
122
136
  );
123
- };
137
+ });
124
138
 
125
- export default memo(List);
139
+ export default List;
@@ -1,30 +1,36 @@
1
1
  import { ActionIcon } from '@lobehub/ui';
2
2
  import { Popconfirm } from 'antd';
3
+ import { useResponsive } from 'antd-style';
3
4
  import { Eraser } from 'lucide-react';
4
5
  import { memo } from 'react';
5
6
  import { useTranslation } from 'react-i18next';
6
7
 
7
8
  import { useSessionStore } from '@/store/session';
8
9
 
10
+ import SaveTopic from '../Footer/SaveTopic';
11
+
9
12
  const ActionsRight = memo(() => {
10
13
  const { t } = useTranslation('setting');
11
14
  const [clearMessage] = useSessionStore((s) => [s.clearMessage, s.updateAgentConfig]);
12
-
15
+ const { mobile } = useResponsive();
13
16
  return (
14
- <Popconfirm
15
- cancelText={t('cancel', { ns: 'common' })}
16
- okButtonProps={{ danger: true }}
17
- okText={t('ok', { ns: 'common' })}
18
- onConfirm={() => clearMessage()}
19
- placement={'topRight'}
20
- title={t('confirmClearCurrentMessages', { ns: 'common' })}
21
- >
22
- <ActionIcon
23
- icon={Eraser}
24
- placement={'bottom'}
25
- title={t('clearCurrentMessages', { ns: 'common' })}
26
- />
27
- </Popconfirm>
17
+ <>
18
+ {mobile && <SaveTopic />}
19
+ <Popconfirm
20
+ cancelText={t('cancel', { ns: 'common' })}
21
+ okButtonProps={{ danger: true }}
22
+ okText={t('ok', { ns: 'common' })}
23
+ onConfirm={() => clearMessage()}
24
+ placement={'topRight'}
25
+ title={t('confirmClearCurrentMessages', { ns: 'common' })}
26
+ >
27
+ <ActionIcon
28
+ icon={Eraser}
29
+ placement={'bottom'}
30
+ title={t('clearCurrentMessages', { ns: 'common' })}
31
+ />
32
+ </Popconfirm>
33
+ </>
28
34
  );
29
35
  });
30
36
 
@@ -1,12 +1,35 @@
1
+ import { createStyles } from 'antd-style';
1
2
  import { ReactNode, memo } from 'react';
2
3
 
4
+ import SafeSpacing from '@/components/SafeSpacing';
5
+ import { CHAT_TEXTAREA_HEIGHT_MOBILE } from '@/const/layoutTokens';
6
+
7
+ const useStyles = createStyles(
8
+ ({ css, token }) => css`
9
+ position: fixed;
10
+ right: 0;
11
+ bottom: 0;
12
+ left: 0;
13
+
14
+ width: 100vw;
15
+
16
+ background: ${token.colorBgLayout};
17
+ `,
18
+ );
19
+
3
20
  interface ChatInputMobileLayoutProps {
4
21
  children: ReactNode;
5
22
  expand?: boolean;
6
23
  }
7
24
 
8
25
  const ChatInputMobileLayout = memo<ChatInputMobileLayoutProps>(({ children }) => {
9
- return <div>{children}</div>;
26
+ const { styles } = useStyles();
27
+ return (
28
+ <>
29
+ <SafeSpacing height={CHAT_TEXTAREA_HEIGHT_MOBILE} mobile position={'bottom'} />
30
+ <div className={styles}>{children}</div>
31
+ </>
32
+ );
10
33
  });
11
34
 
12
35
  export default ChatInputMobileLayout;
@@ -13,8 +13,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
13
13
  import Conversation from './features/Conversation';
14
14
  import Header from './features/Header';
15
15
  import SideBar from './features/Sidebar';
16
+ import DesktopLayout from './layout.desktop';
16
17
  import MobileLayout from './layout.mobile';
17
- import DesktopLayout from './layout.pc';
18
18
 
19
19
  const Chat = memo(() => {
20
20
  const { mobile } = useResponsive();
@@ -11,8 +11,8 @@ import { useSessionStore } from '@/store/session';
11
11
  import { agentSelectors } from '@/store/session/selectors';
12
12
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
13
13
 
14
+ import DesktopLayout from './layout.desktop';
14
15
  import MobileLayout from './layout.mobile';
15
- import DesktopLayout from './layout.pc';
16
16
 
17
17
  const EditPage = memo(() => {
18
18
  const { mobile } = useResponsive();
@@ -4,7 +4,7 @@ import { Flexbox } from 'react-layout-kit';
4
4
  import SafeSpacing from '@/components/SafeSpacing';
5
5
  import { HEADER_HEIGHT } from '@/const/layoutTokens';
6
6
 
7
- import ChatLayout from '../layout.pc';
7
+ import ChatLayout from '../layout.desktop';
8
8
  import Header from './features/Header';
9
9
 
10
10
  const DesktopLayout = memo<PropsWithChildren>(({ children }) => {
@@ -1,6 +1,6 @@
1
1
  import { createStyles } from 'antd-style';
2
2
 
3
- export const useStyles = createStyles(({ css, token }) => ({
3
+ export const useStyles = createStyles(({ css, token, prefixCls }) => ({
4
4
  author: css`
5
5
  font-size: 12px;
6
6
  `,
@@ -22,7 +22,7 @@ export const useStyles = createStyles(({ css, token }) => ({
22
22
  text-align: center;
23
23
  `,
24
24
  loading: css`
25
- .ant-skeleton-content {
25
+ .${prefixCls}-skeleton-content {
26
26
  display: flex;
27
27
  flex-direction: column;
28
28
  }
@@ -30,10 +30,10 @@ export const useStyles = createStyles(({ css, token }) => ({
30
30
  nav: css`
31
31
  padding-top: 4px;
32
32
 
33
- .ant-tabs-tab {
33
+ .${prefixCls}-tabs-tab {
34
34
  margin: 4px !important;
35
35
 
36
- + .ant-tabs-tab {
36
+ + .${prefixCls}-tabs-tab {
37
37
  margin: 4px !important;
38
38
  }
39
39
  }
@@ -10,8 +10,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
10
10
 
11
11
  import AgentCard from './features/AgentCard';
12
12
  import AgentSearchBar from './features/AgentSearchBar';
13
+ import DesktopLayout from './layout.desktop';
13
14
  import MobileLayout from './layout.mobile';
14
- import DesktopLayout from './layout.pc';
15
15
 
16
16
  const Market = memo(() => {
17
17
  const { t } = useTranslation('common');
@@ -5,16 +5,9 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
5
5
  import pkg from '../../package.json';
6
6
 
7
7
  const title = genSiteHeadTitle();
8
- const description = pkg.description;
8
+ const { description, homepage } = pkg;
9
9
  const metadata: Metadata = {
10
10
  appleWebApp: {
11
- startupImage: [
12
- 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/splash-750x1624.png',
13
- {
14
- media: '(device-width: 768px) and (device-height: 1024px)',
15
- url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/splash-2048x2732.png',
16
- },
17
- ],
18
11
  statusBarStyle: 'black-translucent',
19
12
  title: title,
20
13
  },
@@ -23,10 +16,6 @@ const metadata: Metadata = {
23
16
  apple:
24
17
  'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/apple-touch-icon.png',
25
18
  icon: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon-32x32.png',
26
- other: {
27
- rel: 'mask-icon',
28
- url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/safari-pinned-tab.svg',
29
- },
30
19
  shortcut:
31
20
  'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon.ico',
32
21
  },
@@ -37,13 +26,13 @@ const metadata: Metadata = {
37
26
  {
38
27
  alt: title,
39
28
  height: 360,
40
- url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-480x360.png',
29
+ url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-480x270.png',
41
30
  width: 480,
42
31
  },
43
32
  {
44
33
  alt: title,
45
34
  height: 720,
46
- url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-960x720.png',
35
+ url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-960x540.png',
47
36
  width: 960,
48
37
  },
49
38
  ],
@@ -51,13 +40,13 @@ const metadata: Metadata = {
51
40
  siteName: title,
52
41
  title: title,
53
42
  type: 'website',
54
- url: pkg.homepage,
43
+ url: homepage,
55
44
  },
56
45
  themeColor: [
57
46
  { color: '#fff', media: '(prefers-color-scheme: light)' },
58
47
  { color: '#000', media: '(prefers-color-scheme: dark)' },
59
48
  ],
60
- title: genSiteHeadTitle(),
49
+ title: title,
61
50
  viewport: {
62
51
  initialScale: 1,
63
52
  maximumScale: 1,
@@ -7,7 +7,7 @@ import { Flexbox } from 'react-layout-kit';
7
7
 
8
8
  import pkg from '@/../package.json';
9
9
 
10
- const useStyles = createStyles(({ css, token, isDarkMode }) => ({
10
+ const useStyles = createStyles(({ css, token, isDarkMode, prefixCls }) => ({
11
11
  background: css`
12
12
  position: absolute;
13
13
  bottom: -10%;
@@ -42,8 +42,7 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
42
42
  mobile: css`
43
43
  margin-top: -16px;
44
44
 
45
- .ant-tabs-tab,
46
- .ant-tabs-tab + .ant-tabs-tab {
45
+ .${prefixCls}-tabs-tab, .${prefixCls}-tabs-tab + .${prefixCls}-tabs-tab {
47
46
  margin: 4px 8px !important;
48
47
  }
49
48
  `,
@@ -1,7 +1,6 @@
1
1
  import { Form, type ItemGroup, SelectWithImg, SliderWithInput } from '@lobehub/ui';
2
2
  import { Form as AntForm, App, Button, Input, Select } from 'antd';
3
3
  import isEqual from 'fast-deep-equal';
4
- import { changeLanguage } from 'i18next';
5
4
  import { debounce } from 'lodash-es';
6
5
  import { AppWindow, Monitor, Moon, Palette, Sun } from 'lucide-react';
7
6
  import { memo, useCallback, useMemo } from 'react';
@@ -14,6 +13,7 @@ import { localeOptions } from '@/locales/options';
14
13
  import { globalSelectors, useGlobalStore } from '@/store/global';
15
14
  import { useSessionStore } from '@/store/session';
16
15
  import { ConfigKeys } from '@/types/settings';
16
+ import { switchLang } from '@/utils/switchLang';
17
17
 
18
18
  import { ThemeSwatchesNeutral, ThemeSwatchesPrimary } from '../ThemeSwatches';
19
19
 
@@ -107,14 +107,7 @@ const Common = memo(() => {
107
107
  minWidth: undefined,
108
108
  },
109
109
  {
110
- children: (
111
- <Select
112
- onChange={(e) => {
113
- changeLanguage(e);
114
- }}
115
- options={localeOptions}
116
- />
117
- ),
110
+ children: <Select onChange={switchLang} options={localeOptions} />,
118
111
  label: t('settingTheme.lang.title'),
119
112
  name: 'language',
120
113
  },
@@ -9,8 +9,8 @@ import { useSwitchSideBarOnInit } from '@/store/global';
9
9
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
10
10
 
11
11
  import Settings from './features/Settings';
12
+ import DesktopLayout from './layout.desktop';
12
13
  import MobileLayout from './layout.mobile';
13
- import DesktopLayout from './layout.pc';
14
14
 
15
15
  const Setting = memo(() => {
16
16
  const { mobile } = useResponsive();
@@ -9,8 +9,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
9
9
 
10
10
  import Banner from './features/Banner';
11
11
  import Footer from './features/Footer';
12
+ import Layout from './layout.desktop';
12
13
  import Mobile from './layout.mobile';
13
- import Layout from './layout.pc';
14
14
 
15
15
  const Welcome = memo(() => {
16
16
  const { mobile } = useResponsive();
@@ -10,7 +10,7 @@ const WelcomeLayout = memo<PropsWithChildren>(({ children }) => {
10
10
  <AppMobileLayout
11
11
  navBar={<MobileNavBar center={<Logo type={'text'} />} />}
12
12
  showTabBar
13
- style={{ background: theme.colorBgContainer }}
13
+ style={{ background: theme.colorBgLayout }}
14
14
  >
15
15
  {children}
16
16
  </AppMobileLayout>
@@ -4,6 +4,7 @@ export const HEADER_HEIGHT = 64;
4
4
  export const MOBILE_NABBAR_HEIGHT = 44;
5
5
  export const MOBILE_TABBAR_HEIGHT = 48;
6
6
  export const CHAT_TEXTAREA_HEIGHT = 200;
7
+ export const CHAT_TEXTAREA_HEIGHT_MOBILE = 180;
7
8
  export const CHAT_SIDEBAR_WIDTH = 280;
8
9
  export const MARKET_SIDEBAR_WIDTH = 400;
9
10
  export const FOLDER_WIDTH = 256;
@@ -12,7 +12,7 @@ import {
12
12
  export const DEFAULT_BASE_SETTINGS: GlobalBaseSettings = {
13
13
  avatar: '',
14
14
  fontSize: 14,
15
- language: 'zh-CN',
15
+ language: 'en-US',
16
16
  password: '',
17
17
  themeMode: 'auto',
18
18
  };
@@ -15,9 +15,9 @@ import { useStore } from '../store';
15
15
  import LocalPluginItem from './LocalPluginItem';
16
16
  import MarketSettingModal from './MarketSettingModal';
17
17
 
18
- const useStyles = createStyles(({ css }) => ({
18
+ const useStyles = createStyles(({ css, prefixCls }) => ({
19
19
  avatar: css`
20
- .ant-skeleton-header {
20
+ .${prefixCls}-skeleton-header {
21
21
  padding-right: 0;
22
22
  }
23
23
  `,
@@ -4,8 +4,7 @@ export const useIsPWA = () => {
4
4
  const [isPWA, setIsPWA] = useState(false);
5
5
 
6
6
  useEffect(() => {
7
- const isInStandaloneMode = () =>
8
- 'standalone' in window.navigator && window.navigator['standalone'];
7
+ const isInStandaloneMode = () => window.matchMedia('(display-mode: standalone)').matches;
9
8
  if (isInStandaloneMode()) {
10
9
  setIsPWA(true);
11
10
  }
@@ -3,7 +3,6 @@
3
3
  import { App, ConfigProvider } from 'antd';
4
4
  import 'antd/dist/reset.css';
5
5
  import Zh_CN from 'antd/locale/zh_CN';
6
- import { changeLanguage } from 'i18next';
7
6
  import { useRouter } from 'next/navigation';
8
7
  import { PropsWithChildren, memo, useEffect } from 'react';
9
8
 
@@ -12,6 +11,7 @@ import { createI18nNext } from '@/locales/create';
12
11
  import { useGlobalStore, useOnFinishHydrationGlobal } from '@/store/global';
13
12
  import { usePluginStore } from '@/store/plugin';
14
13
  import { useOnFinishHydrationSession, useSessionStore } from '@/store/session';
14
+ import { switchLang } from '@/utils/switchLang';
15
15
 
16
16
  import { useStyles } from './style';
17
17
 
@@ -30,9 +30,7 @@ const Layout = memo<PropsWithChildren>(({ children }) => {
30
30
  }, []);
31
31
 
32
32
  useOnFinishHydrationGlobal((state) => {
33
- i18n.then(() => {
34
- changeLanguage(state.settings.language);
35
- });
33
+ i18n.then(() => switchLang(state.settings.language));
36
34
  });
37
35
 
38
36
  useOnFinishHydrationSession((s, store) => {
@@ -14,29 +14,21 @@ export const createI18nNext = (params: { namespace?: Namespaces[] | Namespaces }
14
14
  ? ['error', 'common', ...namespace]
15
15
  : (['error', 'common', namespace].filter(Boolean) as Namespaces[]);
16
16
 
17
- return (
18
- i18n
19
- // detect user language
20
- // learn more: https://github.com/i18next/i18next-browser-languageDetector
21
- .use(LanguageDetector)
22
- // pass the i18n instance to react-i18next.
23
- .use(initReactI18next)
24
- // init i18next
25
- // for all options read: https://www.i18next.com/overview/configuration-options
26
- .init({
27
- debug: process.env.NODE_ENV === 'development',
28
- defaultNS: ns,
29
- // LanguageDetector config, refs: https://github.com/i18next/i18next-browser-languageDetector
30
- detection: {
31
- caches: [],
32
- },
33
- fallbackLng: 'zh-CN',
34
- interpolation: {
35
- escapeValue: false, // not needed for react as it escapes by default
36
- },
37
- ns,
38
- // resources: getRes(resources, ns),
39
- resources,
40
- })
41
- );
17
+ return i18n
18
+ .use(LanguageDetector)
19
+ .use(initReactI18next)
20
+ .init({
21
+ debug: process.env.NODE_ENV === 'development',
22
+ defaultNS: ns,
23
+ detection: {
24
+ caches: [],
25
+ },
26
+ fallbackLng: 'en-US',
27
+ interpolation: {
28
+ escapeValue: false,
29
+ },
30
+ lng: 'en-US',
31
+ ns,
32
+ resources,
33
+ });
42
34
  };
@@ -1,22 +1,20 @@
1
1
  import { Theme, css } from 'antd-style';
2
2
  import { readableColor } from 'polished';
3
3
 
4
- export default (token: Theme) => css`
5
- .ant-btn {
4
+ export default ({ token, prefixCls }: { prefixCls: string; token: Theme }) => css`
5
+ .${prefixCls}-btn {
6
6
  box-shadow: none;
7
7
  }
8
8
 
9
- .ant-popover {
9
+ .${prefixCls}-popover {
10
10
  z-index: 1100;
11
11
  }
12
12
 
13
- .ant-slider-track,
14
- .ant-tabs-ink-bar,
15
- .ant-switch-checked {
13
+ .${prefixCls}-slider-track, .${prefixCls}-tabs-ink-bar, .${prefixCls}-switch-checked {
16
14
  background: ${token.colorPrimary} !important;
17
15
  }
18
16
 
19
- .ant-btn-primary:not(.ant-btn-dangerous) {
17
+ .${prefixCls}-btn-primary:not(.${prefixCls}-btn-dangerous) {
20
18
  color: ${readableColor(token.colorPrimary)};
21
19
  background: ${token.colorPrimary};
22
20
 
@@ -1,9 +1,9 @@
1
1
  import { css } from 'antd-style';
2
2
 
3
- export default () => css`
3
+ export default ({ prefixCls }: { prefixCls: string }) => css`
4
4
  html,
5
5
  body,
6
- .ant-app {
6
+ .${prefixCls}-app {
7
7
  overflow: hidden;
8
8
  overscroll-behavior: none;
9
9
 
@@ -3,4 +3,9 @@ import { createGlobalStyle } from 'antd-style';
3
3
  import antdOverride from './antdOverride';
4
4
  import global from './global';
5
5
 
6
- export const GlobalStyle = createGlobalStyle(({ theme }) => [global(), antdOverride(theme)]);
6
+ const prefixCls = 'ant';
7
+
8
+ export const GlobalStyle = createGlobalStyle(({ theme }) => [
9
+ global({ prefixCls }),
10
+ antdOverride({ prefixCls, token: theme }),
11
+ ]);
@@ -0,0 +1,6 @@
1
+ import { changeLanguage } from 'i18next';
2
+
3
+ export const switchLang = (lang: string) => {
4
+ changeLanguage(lang);
5
+ document.documentElement.lang = lang;
6
+ };