@lobehub/chat 0.79.8 → 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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
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
+
5
30
  ### [Version 0.79.8](https://github.com/lobehub/lobe-chat/compare/v0.79.7...v0.79.8)
6
31
 
7
32
  <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.8",
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",
@@ -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
  }
@@ -5,7 +5,7 @@ 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
11
  statusBarStyle: 'black-translucent',
@@ -40,7 +40,7 @@ const metadata: Metadata = {
40
40
  siteName: title,
41
41
  title: title,
42
42
  type: 'website',
43
- url: pkg.homepage,
43
+ url: homepage,
44
44
  },
45
45
  themeColor: [
46
46
  { color: '#fff', media: '(prefers-color-scheme: light)' },
@@ -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
  },
@@ -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
  `,
@@ -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
+ };