@lobehub/chat 0.79.8 → 0.80.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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.80.1](https://github.com/lobehub/lobe-chat/compare/v0.80.0...v0.80.1)
6
+
7
+ <sup>Released on **2023-09-27**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: Fix conversation mobile viewarea.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: Fix conversation mobile viewarea ([6668e11](https://github.com/lobehub/lobe-chat/commit/6668e11))
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.80.0](https://github.com/lobehub/lobe-chat/compare/v0.79.8...v0.80.0)
31
+
32
+ <sup>Released on **2023-09-27**</sup>
33
+
34
+ #### ✨ Features
35
+
36
+ - **misc**: Improve user experience and ensure consistency.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's improved
44
+
45
+ - **misc**: Improve user experience and ensure consistency ([abba584](https://github.com/lobehub/lobe-chat/commit/abba584))
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.8](https://github.com/lobehub/lobe-chat/compare/v0.79.7...v0.79.8)
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.8",
3
+ "version": "0.80.1",
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,5 +1,4 @@
1
1
  import { ChatList, RenderMessage } from '@lobehub/ui';
2
- import { createStyles } from 'antd-style';
3
2
  import isEqual from 'fast-deep-equal';
4
3
  import { memo, useCallback } from 'react';
5
4
  import { useTranslation } from 'react-i18next';
@@ -16,22 +15,9 @@ import FunctionCall from './Plugins/FunctionCall';
16
15
  import PluginMessage from './Plugins/PluginMessage';
17
16
  import SkeletonList from './SkeletonList';
18
17
 
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
18
  const List = memo(() => {
32
19
  const init = useSessionChatInit();
33
20
  const { t } = useTranslation('common');
34
- const { styles } = useStyles();
35
21
  const data = useSessionStore(chatSelectors.currentChatsWithGuideMessage, isEqual);
36
22
 
37
23
  const [
@@ -96,7 +82,6 @@ const List = memo(() => {
96
82
 
97
83
  return (
98
84
  <ChatList
99
- className={styles}
100
85
  data={data}
101
86
  enableHistoryCount={enableHistoryCount}
102
87
  historyCount={historyCount}
@@ -1,4 +1,5 @@
1
1
  import { BackBottom } from '@lobehub/ui';
2
+ import { createStyles } from 'antd-style';
2
3
  import { memo, useRef } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
4
5
  import { Flexbox } from 'react-layout-kit';
@@ -10,9 +11,22 @@ import ChatList from './ChatList';
10
11
  import ChatInput from './Input';
11
12
  import ChatScrollAnchor from './ScrollAnchor';
12
13
 
14
+ const useStyles = createStyles(
15
+ ({ css, responsive, stylish }) => css`
16
+ overflow-x: hidden;
17
+ overflow-y: scroll;
18
+ height: 100%;
19
+ ${responsive.mobile} {
20
+ ${stylish.noScrollbar}
21
+ width: 100vw;
22
+ }
23
+ `,
24
+ );
25
+
13
26
  const Conversation = memo<{ mobile?: boolean }>(({ mobile }) => {
14
27
  const ref = useRef(null);
15
28
  const { t } = useTranslation('common');
29
+ const { styles } = useStyles();
16
30
 
17
31
  const useFetchPluginList = usePluginStore((s) => s.useFetchPluginList);
18
32
  useFetchPluginList();
@@ -20,7 +34,7 @@ const Conversation = memo<{ mobile?: boolean }>(({ mobile }) => {
20
34
  return (
21
35
  <Flexbox flex={1} style={{ position: 'relative' }}>
22
36
  <div style={{ flex: 1, overflow: 'hidden', position: 'relative' }}>
23
- <div ref={ref} style={{ height: '100%', overflowY: 'scroll' }}>
37
+ <div className={styles} ref={ref}>
24
38
  {!mobile && <SafeSpacing />}
25
39
  <ChatList />
26
40
  <ChatScrollAnchor />
@@ -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
  },
@@ -4,7 +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
+ export const CHAT_TEXTAREA_HEIGHT_MOBILE = 120;
8
8
  export const CHAT_SIDEBAR_WIDTH = 280;
9
9
  export const MARKET_SIDEBAR_WIDTH = 400;
10
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
  `,
@@ -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
+ };