@lobehub/chat 1.47.10 → 1.47.11

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 1.47.11](https://github.com/lobehub/lobe-chat/compare/v1.47.10...v1.47.11)
6
+
7
+ <sup>Released on **2025-01-21**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Improve code for ai provider.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Improve code for ai provider, closes [#5532](https://github.com/lobehub/lobe-chat/issues/5532) ([ea59e24](https://github.com/lobehub/lobe-chat/commit/ea59e24))
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 1.47.10](https://github.com/lobehub/lobe-chat/compare/v1.47.9...v1.47.10)
6
31
 
7
32
  <sup>Released on **2025-01-21**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Improve code for ai provider."
6
+ ]
7
+ },
8
+ "date": "2025-01-21",
9
+ "version": "1.47.11"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.47.10",
3
+ "version": "1.47.11",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -316,7 +316,7 @@
316
316
  "vitest": "~1.2.2",
317
317
  "vitest-canvas-mock": "^0.3.3"
318
318
  },
319
- "packageManager": "pnpm@9.15.3",
319
+ "packageManager": "pnpm@9.15.4",
320
320
  "publishConfig": {
321
321
  "access": "public",
322
322
  "registry": "https://registry.npmjs.org"
@@ -6,10 +6,9 @@ import { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
- import InstantSwitch from '@/components/InstantSwitch';
10
- import { useAiInfraStore } from '@/store/aiInfra';
11
9
  import { AiProviderListItem } from '@/types/aiProvider';
12
10
 
11
+ import EnableSwitch from './EnableSwitch';
13
12
  import { useStyles } from './style';
14
13
 
15
14
  const { Paragraph } = Typography;
@@ -21,7 +20,6 @@ const ProviderCard = memo<ProviderCardProps>(
21
20
  ({ id, description, name, enabled, source, logo, loading }) => {
22
21
  const { t } = useTranslation('providers');
23
22
  const { cx, styles, theme } = useStyles();
24
- const toggleProviderEnabled = useAiInfraStore((s) => s.toggleProviderEnabled);
25
23
 
26
24
  if (loading)
27
25
  return (
@@ -73,13 +71,7 @@ const ProviderCard = memo<ProviderCardProps>(
73
71
  <Divider style={{ margin: '4px 0' }} />
74
72
  <Flexbox horizontal justify={'space-between'} paddingBlock={'8px 0'}>
75
73
  <div />
76
- <InstantSwitch
77
- enabled={enabled}
78
- onChange={async (checked) => {
79
- await toggleProviderEnabled(id, checked);
80
- }}
81
- size={'small'}
82
- />
74
+ <EnableSwitch enabled={enabled} id={id} />
83
75
  </Flexbox>
84
76
  </Flexbox>
85
77
  </Flexbox>
@@ -0,0 +1,29 @@
1
+ import { FC } from 'react';
2
+
3
+ import InstantSwitch from '@/components/InstantSwitch';
4
+ import { useAiInfraStore } from '@/store/aiInfra';
5
+
6
+ interface SwitchProps {
7
+ Component?: FC<{ enabled: boolean, id: string; }>;
8
+ enabled: boolean;
9
+ id: string;
10
+ }
11
+
12
+ const Switch = ({ id, Component, enabled }: SwitchProps) => {
13
+ const [toggleProviderEnabled] = useAiInfraStore((s) => [s.toggleProviderEnabled]);
14
+
15
+ // slot for cloud
16
+ if (Component) return <Component enabled={enabled} id={id} />;
17
+
18
+ return (
19
+ <InstantSwitch
20
+ enabled={enabled}
21
+ onChange={async (checked) => {
22
+ await toggleProviderEnabled(id, checked);
23
+ }}
24
+ size={'small'}
25
+ />
26
+ );
27
+ };
28
+
29
+ export default Switch;
@@ -29,6 +29,10 @@ const useStyles = createStyles(({ css, responsive, token }) => ({
29
29
  ${responsive.desktop} {
30
30
  grid-template-columns: repeat(3, 1fr);
31
31
  }
32
+
33
+ ${responsive.md} {
34
+ grid-template-columns: repeat(1, 1fr);
35
+ }
32
36
  `,
33
37
  }));
34
38
 
@@ -51,7 +55,7 @@ const List = memo(() => {
51
55
  {t('list.title.enabled')}
52
56
  </Typography.Text>
53
57
  </Flexbox>
54
- <Grid>
58
+ <Grid className={styles.grid}>
55
59
  {loadingArr.map((item) => (
56
60
  <Card enabled={false} id={item} key={item} loading source={'builtin'} />
57
61
  ))}
@@ -50,7 +50,7 @@ export const Placeholder = memo(() => {
50
50
  });
51
51
 
52
52
  export const SkeletonList = memo(() => (
53
- <Flexbox gap={4} style={{ paddingTop: 6 }}>
53
+ <Flexbox flex={1} gap={4} style={{ paddingTop: 6 }}>
54
54
  {Array.from({ length: 6 }).map((_, i) => (
55
55
  <Placeholder key={i} />
56
56
  ))}
@@ -31,7 +31,7 @@ const Layout = memo(({ children, mobile }: ProviderMenuProps) => {
31
31
 
32
32
  const width = mobile ? undefined : 260;
33
33
  return (
34
- <Flexbox style={{ minWidth: width, overflow: 'scroll' }} width={width}>
34
+ <Flexbox style={{ minWidth: width, overflow: mobile ? undefined : 'scroll' }} width={width}>
35
35
  <Flexbox
36
36
  gap={8}
37
37
  horizontal
@@ -1,27 +0,0 @@
1
- 'use client';
2
-
3
- import { useLayoutEffect } from 'react';
4
- import urlJoin from 'url-join';
5
-
6
- import { useQuery } from '@/hooks/useQuery';
7
- import { useQueryRoute } from '@/hooks/useQueryRoute';
8
- import { SettingsTabs } from '@/store/global/initialState';
9
-
10
- /**
11
- * @description: Settings Modal (intercepting routes fallback when hard refresh)
12
- * @example: /settings/modal?tab=common => /settings/common
13
- * @refs: https://github.com/lobehub/lobe-chat/discussions/2295#discussioncomment-9290942
14
- */
15
-
16
- const SettingsModalFallback = () => {
17
- const { tab = SettingsTabs.Common } = useQuery();
18
- const router = useQueryRoute();
19
-
20
- useLayoutEffect(() => {
21
- router.replace(urlJoin('/settings', tab as SettingsTabs), { query: { tab: '' } });
22
- }, []);
23
-
24
- return null;
25
- };
26
-
27
- export default SettingsModalFallback;