@lobehub/chat 0.127.0 → 0.127.2

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 (69) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +8 -8
  3. package/README.zh-CN.md +8 -8
  4. package/package.json +1 -1
  5. package/src/app/chat/(desktop)/layout.desktop.tsx +1 -3
  6. package/src/app/chat/(mobile)/index.tsx +2 -5
  7. package/src/app/chat/features/ChatHeader/SettingButton.tsx +1 -2
  8. package/src/app/home/Redirect.tsx +0 -4
  9. package/src/app/market/(desktop)/layout.desktop.tsx +1 -4
  10. package/src/app/market/(mobile)/layout.mobile.tsx +1 -4
  11. package/src/app/market/features/AgentDetailContent/AgentInfo/Header.tsx +0 -4
  12. package/src/app/settings/(desktop)/features/Header.tsx +3 -4
  13. package/src/app/settings/(desktop)/features/SideBar.tsx +42 -0
  14. package/src/app/settings/(desktop)/index.tsx +4 -3
  15. package/src/app/settings/(desktop)/layout.desktop.tsx +14 -9
  16. package/src/app/settings/(desktop)/layout.responsive.tsx +4 -4
  17. package/src/app/settings/(mobile)/features/ExtraList.tsx +7 -5
  18. package/src/app/settings/(mobile)/features/Header/index.tsx +8 -5
  19. package/src/app/settings/(mobile)/index.tsx +1 -3
  20. package/src/app/settings/(mobile)/layout.mobile.tsx +8 -6
  21. package/src/app/settings/(mobile)/mobile/index.tsx +3 -5
  22. package/src/app/settings/agent/Agent.tsx +0 -4
  23. package/src/app/settings/agent/layout.tsx +9 -1
  24. package/src/app/settings/agent/page.tsx +17 -2
  25. package/src/app/settings/common/index.tsx +0 -3
  26. package/src/app/settings/common/layout.tsx +9 -1
  27. package/src/app/settings/features/SettingList/Item.tsx +50 -0
  28. package/src/app/settings/features/{SideBar/List.tsx → SettingList/index.tsx} +14 -15
  29. package/src/app/settings/layout.server.tsx +10 -3
  30. package/src/app/settings/llm/Azure/index.tsx +78 -106
  31. package/src/app/settings/llm/Bedrock/index.tsx +60 -89
  32. package/src/app/settings/llm/Google/index.tsx +26 -55
  33. package/src/app/settings/llm/Moonshot/index.tsx +29 -54
  34. package/src/app/settings/llm/Ollama/index.tsx +35 -61
  35. package/src/app/settings/llm/OpenAI/index.tsx +91 -107
  36. package/src/app/settings/llm/Zhipu/index.tsx +29 -54
  37. package/src/app/settings/llm/components/ProviderConfig/index.tsx +58 -0
  38. package/src/app/settings/llm/index.tsx +42 -0
  39. package/src/app/settings/llm/layout.tsx +9 -1
  40. package/src/app/settings/llm/page.tsx +6 -46
  41. package/src/app/settings/tts/layout.tsx +9 -1
  42. package/src/app/settings/tts/page.tsx +17 -2
  43. package/src/const/settings.ts +1 -0
  44. package/src/features/MobileTabBar/index.tsx +7 -14
  45. package/src/features/SideBar/BottomActions.tsx +3 -9
  46. package/src/features/SideBar/TopActions.tsx +2 -7
  47. package/src/features/SideBar/index.tsx +7 -5
  48. package/src/layout/AppLayout.desktop.tsx +8 -3
  49. package/src/layout/AppLayout.mobile.tsx +4 -2
  50. package/src/layout/ResponsiveLayout.client.tsx +7 -7
  51. package/src/layout/ResponsiveLayout.server.tsx +6 -6
  52. package/src/services/_auth.test.ts +132 -0
  53. package/src/services/_auth.ts +1 -1
  54. package/src/store/global/hooks/index.ts +1 -1
  55. package/src/store/global/slices/common/action.test.ts +0 -12
  56. package/src/store/global/slices/common/action.ts +1 -6
  57. package/src/store/global/slices/common/initialState.ts +0 -2
  58. package/src/store/global/slices/settings/action.test.ts +0 -13
  59. package/src/store/global/slices/settings/action.ts +0 -5
  60. package/src/store/global/slices/settings/selectors/modelProvider.ts +7 -0
  61. package/src/types/settings/modelProvider.ts +1 -0
  62. package/src/app/settings/agent/index.tsx +0 -21
  63. package/src/app/settings/features/SideBar/Item.tsx +0 -44
  64. package/src/app/settings/features/SideBar/index.tsx +0 -42
  65. package/src/app/settings/tts/index.tsx +0 -21
  66. package/src/store/global/hooks/useSwitchSettingsOnInit.ts +0 -12
  67. package/src/store/global/hooks/useSwitchSideBarOnInit.ts +0 -13
  68. /package/src/app/settings/llm/{Checker.tsx → components/Checker.tsx} +0 -0
  69. /package/src/app/settings/llm/{useSyncSettings.ts → components/ProviderConfig/useSyncSettings.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.127.2](https://github.com/lobehub/lobe-chat/compare/v0.127.1...v0.127.2)
6
+
7
+ <sup>Released on **2024-02-14**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor the sidebar to fix first render state.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor the sidebar to fix first render state, closes [#1301](https://github.com/lobehub/lobe-chat/issues/1301) ([c477491](https://github.com/lobehub/lobe-chat/commit/c477491))
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.127.1](https://github.com/lobehub/lobe-chat/compare/v0.127.0...v0.127.1)
31
+
32
+ <sup>Released on **2024-02-14**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Improve settings tabs style and refactor the LLM setting page.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Improve settings tabs style and refactor the LLM setting page, closes [#1299](https://github.com/lobehub/lobe-chat/issues/1299) ([31f6f15](https://github.com/lobehub/lobe-chat/commit/31f6f15))
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.127.0](https://github.com/lobehub/lobe-chat/compare/v0.126.5...v0.127.0)
6
56
 
7
57
  <sup>Released on **2024-02-13**</sup>
package/README.md CHANGED
@@ -225,14 +225,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
225
225
 
226
226
  <!-- AGENT LIST -->
227
227
 
228
- | Recent Submits | Description |
229
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
- | [Product Review](https://chat-preview.lobehub.com/market?agent=product-reviews)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-11**</sup> | Expert in creating persuasive product testimonials highlighting the benefits and value proposition of \[your product/service].<br/>`ecommerce` |
231
- | [Tarot Reader](https://chat-preview.lobehub.com/market?agent=augur)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-02-10**</sup> | Specializes in tarot reading and interpreting tarot cards<br/>`tarot-reading` `interpretation` `advice` |
232
- | [Happy Loong Year](https://chat-preview.lobehub.com/market?agent=happy-loong-year)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2024-02-10**</sup> | Loong Year's Assistant combines traditional and modern elements to create interesting New Year blessings.<br/>`new-years-greetings` `creativity` `copywriting` `dragon-year` |
233
- | [Vocabulary Wizard](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating vocabulary lists and MCQ tests<br/>`vocabulary` `academic-word-list` `language-learning` `testing` |
234
-
235
- > 📊 Total agents: [<kbd>**173**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
228
+ | Recent Submits | Description |
229
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
230
+ | [Product Copywriting](https://chat-preview.lobehub.com/market?agent=copywriting)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-14**</sup> | Expert in persuasive copywriting and consumer psychology<br/>`ecommerce` |
231
+ | [Private Domain Operations Expert](https://chat-preview.lobehub.com/market?agent=gl-syyy)<br/><sup>By **[guling-io](https://github.com/guling-io)** on **2024-02-14**</sup> | Specializing in private domain operations, traffic acquisition, user retention, conversion, and content planning. Familiar with marketing theories and related classic works.<br/>`private-domain-operations` `traffic-acquisition` `user-retention` `conversion` `content-planning` |
232
+ | [Self-Media Operation Expert](https://chat-preview.lobehub.com/market?agent=gl-zmtyy)<br/><sup>By **[guling-io](https://github.com/guling-io)** on **2024-02-14**</sup> | Specialized in self-media operation and content creation<br/>`self-media-operation` `social-media` `content-creation` `fan-growth` `brand-promotion` |
233
+ | [Product Description](https://chat-preview.lobehub.com/market?agent=product-description)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-14**</sup> | Craft compelling product descriptions that boost e-commerce sales<br/>`ecommerce` |
234
+
235
+ > 📊 Total agents: [<kbd>**177**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
236
236
 
237
237
  <!-- AGENT LIST -->
238
238
 
package/README.zh-CN.md CHANGED
@@ -205,14 +205,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
205
205
 
206
206
  <!-- AGENT LIST -->
207
207
 
208
- | 最近新增 | 助手说明 |
209
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
210
- | [产品评价](https://chat-preview.lobehub.com/market?agent=product-reviews)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-11**</sup> | 擅长撰写有说服力的产品推荐,突出 \[您的产品 / 服务] 的优势和价值主张。<br/>`电子商务` |
211
- | [塔罗占卜师](https://chat-preview.lobehub.com/market?agent=augur)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-02-10**</sup> | 擅长塔罗占卜,会对塔罗牌进行解读<br/>`塔罗占卜` `解读` `建议` |
212
- | [新年快乐](https://chat-preview.lobehub.com/market?agent=happy-loong-year)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2024-02-10**</sup> | 龙年拜年小助手,结合传统与现代元素,创造有趣的龙年祝福语。<br/>`拜年祝福` `创意` `文案` `龙年` |
213
- | [词汇大师](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 擅长生成词汇列表和多项选择测试<br/>`词汇` `学术词汇表` `语言学习` `测试` |
214
-
215
- > 📊 Total agents: [<kbd>**173**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
208
+ | 最近新增 | 助手说明 |
209
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
210
+ | [产品文案撰写](https://chat-preview.lobehub.com/market?agent=copywriting)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-14**</sup> | 精通有说服力的文案撰写和消费者心理学<br/>`电子商务` |
211
+ | [私域运营专家](https://chat-preview.lobehub.com/market?agent=gl-syyy)<br/><sup>By **[guling-io](https://github.com/guling-io)** on **2024-02-14**</sup> | 擅长私域运营、引流、承接、转化和内容策划,熟悉营销理论和相关经典著作。<br/>`私域运营` `引流` `承接` `转化` `内容策划` |
212
+ | [自媒体运营专家](https://chat-preview.lobehub.com/market?agent=gl-zmtyy)<br/><sup>By **[guling-io](https://github.com/guling-io)** on **2024-02-14**</sup> | 擅长自媒体运营与内容创作<br/>`自媒体运营` `社交媒体` `内容创作` `粉丝增长` `品牌推广` |
213
+ | [产品描述](https://chat-preview.lobehub.com/market?agent=product-description)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-14**</sup> | 打造引人入胜的产品描述,提升电子商务销售业绩<br/>`电子商务` |
214
+
215
+ > 📊 Total agents: [<kbd>**177**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
216
216
 
217
217
  <!-- AGENT LIST -->
218
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.127.0",
3
+ "version": "0.127.2",
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",
@@ -4,15 +4,13 @@ import { PropsWithChildren, memo } from 'react';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import AppLayoutDesktop from '@/layout/AppLayout.desktop';
7
- import { useSwitchSideBarOnInit } from '@/store/global';
8
7
  import { SidebarTabKey } from '@/store/global/initialState';
9
8
 
10
9
  import ResponsiveSessionList from './features/SessionList';
11
10
 
12
11
  export default memo(({ children }: PropsWithChildren) => {
13
- useSwitchSideBarOnInit(SidebarTabKey.Chat);
14
12
  return (
15
- <AppLayoutDesktop>
13
+ <AppLayoutDesktop sidebarKey={SidebarTabKey.Chat}>
16
14
  <ResponsiveSessionList />
17
15
  <Flexbox
18
16
  flex={1}
@@ -4,16 +4,13 @@ import { useRouter } from 'next/navigation';
4
4
  import { memo, useEffect } from 'react';
5
5
 
6
6
  import AppLayoutMobile from '@/layout/AppLayout.mobile';
7
- import { useSwitchSideBarOnInit } from '@/store/global';
8
- import { SidebarTabKey } from '@/store/global/slices/common/initialState';
7
+ import { SidebarTabKey } from '@/store/global/initialState';
9
8
 
10
9
  import PageTitle from '../features/PageTitle';
11
10
  import SessionHeader from './features/SessionHeader';
12
11
  import SessionList from './features/SessionList';
13
12
 
14
13
  const ChatMobilePage = memo(() => {
15
- useSwitchSideBarOnInit(SidebarTabKey.Chat);
16
-
17
14
  const router = useRouter();
18
15
  useEffect(() => {
19
16
  router.prefetch('/chat/mobile');
@@ -21,7 +18,7 @@ const ChatMobilePage = memo(() => {
21
18
  }, []);
22
19
 
23
20
  return (
24
- <AppLayoutMobile navBar={<SessionHeader />} showTabBar>
21
+ <AppLayoutMobile navBar={<SessionHeader />} showTabBar tabBarKey={SidebarTabKey.Chat}>
25
22
  <PageTitle />
26
23
  <SessionList />
27
24
  </AppLayoutMobile>
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
 
7
7
  import { DESKTOP_HEADER_ICON_SIZE, MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
8
8
  import { useGlobalStore } from '@/store/global';
9
- import { SettingsTabs, SidebarTabKey } from '@/store/global/slices/common/initialState';
9
+ import { SidebarTabKey } from '@/store/global/initialState';
10
10
  import { useSessionStore } from '@/store/session';
11
11
  import { sessionSelectors } from '@/store/session/selectors';
12
12
  import { pathString } from '@/utils/url';
@@ -22,7 +22,6 @@ const SettingButton = memo<{ mobile?: boolean }>(({ mobile }) => {
22
22
  onClick={() => {
23
23
  if (isInbox) {
24
24
  useGlobalStore.setState({
25
- settingsTab: SettingsTabs.Agent,
26
25
  sidebarKey: SidebarTabKey.Setting,
27
26
  });
28
27
  router.push('/settings/agent');
@@ -5,8 +5,6 @@ import { memo, useEffect } from 'react';
5
5
 
6
6
  import { messageService } from '@/services/message';
7
7
  import { sessionService } from '@/services/session';
8
- import { useGlobalStore } from '@/store/global';
9
- import { SidebarTabKey } from '@/store/global/initialState';
10
8
  import { useSessionStore } from '@/store/session';
11
9
 
12
10
  const checkHasConversation = async () => {
@@ -21,8 +19,6 @@ const Redirect = memo(() => {
21
19
 
22
20
  useEffect(() => {
23
21
  checkHasConversation().then((hasData) => {
24
- useGlobalStore.getState().switchSideBar(SidebarTabKey.Chat);
25
-
26
22
  if (hasData) {
27
23
  router.replace('/chat');
28
24
 
@@ -7,7 +7,6 @@ import { Center, Flexbox } from 'react-layout-kit';
7
7
  import SafeSpacing from '@/components/SafeSpacing';
8
8
  import { MAX_WIDTH } from '@/const/layoutTokens';
9
9
  import AppLayoutDesktop from '@/layout/AppLayout.desktop';
10
- import { useSwitchSideBarOnInit } from '@/store/global';
11
10
  import { SidebarTabKey } from '@/store/global/initialState';
12
11
 
13
12
  import Header from './features/Header';
@@ -30,10 +29,8 @@ const useStyles = createStyles(({ css }) => ({
30
29
  const MarketLayout = memo<PropsWithChildren>(({ children }) => {
31
30
  const { theme, styles } = useStyles();
32
31
 
33
- useSwitchSideBarOnInit(SidebarTabKey.Market);
34
-
35
32
  return (
36
- <AppLayoutDesktop>
33
+ <AppLayoutDesktop sidebarKey={SidebarTabKey.Market}>
37
34
  <Flexbox
38
35
  flex={1}
39
36
  height={'100%'}
@@ -5,7 +5,6 @@ import { PropsWithChildren } from 'react';
5
5
  import { Flexbox } from 'react-layout-kit';
6
6
 
7
7
  import AppLayoutMobile from '@/layout/AppLayout.mobile';
8
- import { useSwitchSideBarOnInit } from '@/store/global';
9
8
  import { SidebarTabKey } from '@/store/global/initialState';
10
9
 
11
10
  import Header from './features/Header';
@@ -13,10 +12,8 @@ import Header from './features/Header';
13
12
  const DetailModal = dynamic(() => import('./features/AgentDetail'));
14
13
 
15
14
  const MarketLayout = ({ children }: PropsWithChildren) => {
16
- useSwitchSideBarOnInit(SidebarTabKey.Market);
17
-
18
15
  return (
19
- <AppLayoutMobile navBar={<Header />} showTabBar>
16
+ <AppLayoutMobile navBar={<Header />} showTabBar tabBarKey={SidebarTabKey.Market}>
20
17
  <Flexbox flex={1} gap={16} style={{ padding: 16 }}>
21
18
  {children}
22
19
  </Flexbox>
@@ -5,8 +5,6 @@ import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { Center } from 'react-layout-kit';
7
7
 
8
- import { useGlobalStore } from '@/store/global';
9
- import { SidebarTabKey } from '@/store/global/initialState';
10
8
  import { agentMarketSelectors, useMarketStore } from '@/store/market';
11
9
  import { useSessionStore } from '@/store/session';
12
10
 
@@ -18,7 +16,6 @@ const Header = memo(() => {
18
16
  const { t } = useTranslation('market');
19
17
  const { styles, theme } = useStyles();
20
18
  const createSession = useSessionStore((s) => s.createSession);
21
- const switchSideBar = useGlobalStore((s) => s.switchSideBar);
22
19
  const agentItem = useMarketStore(agentMarketSelectors.currentAgentItem);
23
20
  const { message } = App.useApp();
24
21
 
@@ -56,7 +53,6 @@ const Header = memo(() => {
56
53
  if (!agentItem) return;
57
54
 
58
55
  createSession({ config, meta });
59
- switchSideBar(SidebarTabKey.Chat);
60
56
  }}
61
57
  type={'primary'}
62
58
  >
@@ -2,17 +2,16 @@ import { ChatHeader, ChatHeaderTitle } from '@lobehub/ui';
2
2
  import { memo } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
 
5
- import { useGlobalStore } from '@/store/global';
5
+ import { SettingsTabs } from '@/store/global/initialState';
6
6
 
7
- const Header = memo(() => {
7
+ const Header = memo(({ activeTab }: { activeTab: SettingsTabs }) => {
8
8
  const { t } = useTranslation('setting');
9
- const tab = useGlobalStore((s) => s.settingsTab);
10
9
 
11
10
  return (
12
11
  <ChatHeader
13
12
  left={
14
13
  <div style={{ paddingLeft: 8 }}>
15
- <ChatHeaderTitle title={t(`tab.${tab}`)} />
14
+ <ChatHeaderTitle title={t(`tab.${activeTab}`)} />
16
15
  </div>
17
16
  }
18
17
  />
@@ -0,0 +1,42 @@
1
+ import { createStyles, useResponsive } from 'antd-style';
2
+ import { memo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Flexbox } from 'react-layout-kit';
5
+
6
+ import SettingList, { SettingListProps } from '../../features/SettingList';
7
+ import UpgradeAlert from '../../features/UpgradeAlert';
8
+
9
+ const useStyles = createStyles(({ stylish, token, css }) => ({
10
+ body: stylish.noScrollbar,
11
+ container: css`
12
+ border-inline-end: 1px solid ${token.colorBorder};
13
+ `,
14
+ logo: css`
15
+ fill: ${token.colorText};
16
+ `,
17
+ top: css`
18
+ font-size: 20px;
19
+ font-weight: bold;
20
+ `,
21
+ }));
22
+
23
+ const SideBar = memo<SettingListProps>(({ activeTab }) => {
24
+ const { styles } = useStyles();
25
+
26
+ const { t } = useTranslation('common');
27
+ const { mobile } = useResponsive();
28
+
29
+ return (
30
+ <Flexbox className={styles.container} width={280}>
31
+ <Flexbox className={styles.top} padding={16}>
32
+ {t('setting')}
33
+ </Flexbox>
34
+ <Flexbox gap={8} style={{ paddingInline: 8 }}>
35
+ <UpgradeAlert />
36
+ <SettingList activeTab={activeTab} mobile={mobile} />
37
+ </Flexbox>
38
+ </Flexbox>
39
+ );
40
+ });
41
+
42
+ export default SideBar;
@@ -4,17 +4,18 @@ import dynamic from 'next/dynamic';
4
4
  import { FC, memo } from 'react';
5
5
 
6
6
  import ResponsiveIndex from '@/components/ResponsiveIndex';
7
+ import { SettingsTabs } from '@/store/global/initialState';
7
8
 
8
9
  import Common from '../common';
9
10
  import { SettingsCommonProps } from '../common/Common';
10
- import Layout from './layout.desktop';
11
+ import DesktopLayout from './layout.desktop';
11
12
 
12
13
  const Mobile: FC = dynamic(() => import('../(mobile)'), { ssr: false }) as FC;
13
14
 
14
15
  export default memo<SettingsCommonProps>((props) => (
15
16
  <ResponsiveIndex Mobile={Mobile}>
16
- <Layout>
17
+ <DesktopLayout activeTab={SettingsTabs.Common}>
17
18
  <Common {...props} />
18
- </Layout>
19
+ </DesktopLayout>
19
20
  </ResponsiveIndex>
20
21
  ));
@@ -1,23 +1,26 @@
1
1
  'use client';
2
2
 
3
- import { PropsWithChildren, memo } from 'react';
3
+ import { ReactNode, memo } from 'react';
4
4
  import { Center, Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import SafeSpacing from '@/components/SafeSpacing';
7
7
  import AppLayoutDesktop from '@/layout/AppLayout.desktop';
8
- import { useSwitchSideBarOnInit } from '@/store/global';
9
- import { SidebarTabKey } from '@/store/global/initialState';
8
+ import { SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
10
9
 
11
- import SideBar from '../features/SideBar';
12
10
  import Header from './features/Header';
11
+ import SideBar from './features/SideBar';
13
12
 
14
- export default memo(({ children }: PropsWithChildren) => {
15
- useSwitchSideBarOnInit(SidebarTabKey.Setting);
13
+ export interface DesktopLayoutProps {
14
+ activeTab: SettingsTabs;
15
+ children: ReactNode;
16
+ }
17
+
18
+ const DesktopLayout = memo<DesktopLayoutProps>(({ children, activeTab }) => {
16
19
  return (
17
- <AppLayoutDesktop>
18
- <SideBar />
20
+ <AppLayoutDesktop sidebarKey={SidebarTabKey.Setting}>
21
+ <SideBar activeTab={activeTab} />
19
22
  <Flexbox flex={1} height={'100%'} style={{ position: 'relative' }}>
20
- <Header />
23
+ <Header activeTab={activeTab} />
21
24
  <Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
22
25
  <SafeSpacing />
23
26
  <Center gap={16} width={'100%'}>
@@ -28,3 +31,5 @@ export default memo(({ children }: PropsWithChildren) => {
28
31
  </AppLayoutDesktop>
29
32
  );
30
33
  });
34
+
35
+ export default DesktopLayout;
@@ -1,16 +1,16 @@
1
1
  'use client';
2
2
 
3
3
  import dynamic from 'next/dynamic';
4
- import { FC, PropsWithChildren, memo } from 'react';
4
+ import { FC, memo } from 'react';
5
5
 
6
6
  import ResponsiveLayout from '@/layout/ResponsiveLayout.client';
7
7
 
8
- import DesktopLayout from './layout.desktop';
8
+ import DesktopLayout, { DesktopLayoutProps } from './layout.desktop';
9
9
 
10
10
  const MobileLayout = dynamic(() => import('../(mobile)/layout.mobile'), { ssr: false }) as FC;
11
11
 
12
- export default memo(({ children }: PropsWithChildren) => (
13
- <ResponsiveLayout Desktop={DesktopLayout} Mobile={MobileLayout}>
12
+ export default memo<DesktopLayoutProps>(({ children, activeTab }) => (
13
+ <ResponsiveLayout Desktop={DesktopLayout} Mobile={MobileLayout} activeTab={activeTab}>
14
14
  {children}
15
15
  </ResponsiveLayout>
16
16
  ));
@@ -7,15 +7,17 @@ import { useTranslation } from 'react-i18next';
7
7
  import { ABOUT, CHANGELOG, FEEDBACK } from '@/const/url';
8
8
  import { useImportConfig } from '@/hooks/useImportConfig';
9
9
  import { configService } from '@/services/config';
10
- import { useGlobalStore } from '@/store/global';
10
+ import { SettingsTabs } from '@/store/global/initialState';
11
11
 
12
- import Item from '../../features/SideBar/Item';
12
+ import Item from '../../features/SettingList/Item';
13
13
 
14
- const ExtraList = memo(() => {
14
+ interface ExtraListProps {
15
+ activeTab?: SettingsTabs;
16
+ }
17
+ const ExtraList = memo<ExtraListProps>(({ activeTab }) => {
15
18
  const { t } = useTranslation('common');
16
19
 
17
20
  const { importConfig } = useImportConfig();
18
- const tab = useGlobalStore((s) => s.settingsTab);
19
21
  const { mobile } = useResponsive();
20
22
  const items = [
21
23
  {
@@ -59,7 +61,7 @@ const ExtraList = memo(() => {
59
61
  </Upload>
60
62
  {items.map(({ value, icon, label, onClick }) => (
61
63
  <div key={value} onClick={onClick}>
62
- <Item active={mobile ? false : tab === value} icon={icon} label={label} />
64
+ <Item active={mobile ? false : activeTab === value} icon={icon} label={label} />
63
65
  </div>
64
66
  ))}
65
67
  </>
@@ -3,18 +3,21 @@ import { useRouter } from 'next/navigation';
3
3
  import { memo } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
- import { useGlobalStore } from '@/store/global';
6
+ import { SettingsTabs } from '@/store/global/initialState';
7
7
 
8
- const Header = memo(() => {
8
+ interface HeaderProps {
9
+ activeTab: SettingsTabs;
10
+ }
11
+
12
+ const Header = memo<HeaderProps>(({ activeTab }) => {
9
13
  const { t } = useTranslation('setting');
10
- const tab = useGlobalStore((s) => s.settingsTab);
11
14
 
12
15
  const router = useRouter();
13
16
 
14
17
  return (
15
18
  <MobileNavBar
16
- center={<MobileNavBarTitle title={t(`tab.${tab}`)} />}
17
- onBackClick={() => router.back()}
19
+ center={<MobileNavBarTitle title={t(`tab.${activeTab}`)} />}
20
+ onBackClick={() => router.push('/settings')}
18
21
  showBackButton
19
22
  />
20
23
  );
@@ -1,3 +1 @@
1
- import Index from './mobile';
2
-
3
- export default () => <Index />;
1
+ export { default } from './mobile';
@@ -1,18 +1,20 @@
1
1
  'use client';
2
2
 
3
- import { PropsWithChildren, memo } from 'react';
3
+ import { ReactNode, memo } from 'react';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import AppLayoutMobile from '@/layout/AppLayout.mobile';
7
- import { useSwitchSideBarOnInit } from '@/store/global';
8
- import { SidebarTabKey } from '@/store/global/initialState';
7
+ import { SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
9
8
 
10
9
  import Header from './features/Header';
11
10
 
12
- export default memo(({ children }: PropsWithChildren) => {
13
- useSwitchSideBarOnInit(SidebarTabKey.Setting);
11
+ export interface SettingLayoutProps {
12
+ activeTab: SettingsTabs;
13
+ children: ReactNode;
14
+ }
15
+ export default memo(({ children, activeTab }: SettingLayoutProps) => {
14
16
  return (
15
- <AppLayoutMobile navBar={<Header />}>
17
+ <AppLayoutMobile navBar={<Header activeTab={activeTab} />} tabBarKey={SidebarTabKey.Setting}>
16
18
  <Flexbox style={{ overflow: 'auto' }}>{children}</Flexbox>
17
19
  </AppLayoutMobile>
18
20
  );
@@ -7,11 +7,10 @@ import { Center } from 'react-layout-kit';
7
7
 
8
8
  import { CURRENT_VERSION } from '@/const/version';
9
9
  import AvatarWithUpload from '@/features/AvatarWithUpload';
10
- import { useGlobalStore, useSwitchSideBarOnInit } from '@/store/global';
11
- import { SidebarTabKey } from '@/store/global/initialState';
10
+ import { useGlobalStore } from '@/store/global';
12
11
  import { commonSelectors } from '@/store/global/selectors';
13
12
 
14
- import List from '../../features/SideBar/List';
13
+ import SettingList from '../../features/SettingList';
15
14
  import AvatarBanner from '../features/AvatarBanner';
16
15
  import ExtraList from '../features/ExtraList';
17
16
  import Layout from './layout.mobile';
@@ -28,7 +27,6 @@ const useStyles = createStyles(({ css, token }) => ({
28
27
  }));
29
28
 
30
29
  const Setting = memo(() => {
31
- useSwitchSideBarOnInit(SidebarTabKey.Setting);
32
30
  const avatar = useGlobalStore(commonSelectors.userAvatar);
33
31
  const { styles } = useStyles();
34
32
 
@@ -40,7 +38,7 @@ const Setting = memo(() => {
40
38
  </Center>
41
39
  </AvatarBanner>
42
40
  <div style={{ width: '100%' }}>
43
- <List />
41
+ <SettingList />
44
42
  <div className={styles.divider} />
45
43
  <ExtraList />
46
44
  <Center style={{ paddingInline: 64 }}>
@@ -3,13 +3,9 @@ import { memo } from 'react';
3
3
 
4
4
  import AgentSetting from '@/features/AgentSetting';
5
5
  import { useGlobalStore } from '@/store/global';
6
- import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
7
- import { SettingsTabs } from '@/store/global/initialState';
8
6
  import { settingsSelectors } from '@/store/global/selectors';
9
7
 
10
8
  const Agent = memo(() => {
11
- useSwitchSideBarOnInit(SettingsTabs.Agent);
12
-
13
9
  const config = useGlobalStore(settingsSelectors.defaultAgentConfig, isEqual);
14
10
  const meta = useGlobalStore(settingsSelectors.defaultAgentMeta, isEqual);
15
11
  const [updateAgent] = useGlobalStore((s) => [s.updateDefaultAgent]);
@@ -1 +1,9 @@
1
- export { default } from '../layout.server';
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ import { SettingsTabs } from '@/store/global/initialState';
4
+
5
+ import SettingLayout from '../layout.server';
6
+
7
+ export default ({ children }: PropsWithChildren) => {
8
+ return <SettingLayout activeTab={SettingsTabs.Agent}>{children}</SettingLayout>;
9
+ };
@@ -1,3 +1,18 @@
1
- import Index from './index';
1
+ 'use client';
2
2
 
3
- export default () => <Index />;
3
+ import { memo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ import PageTitle from '@/components/PageTitle';
7
+
8
+ import Agent from './Agent';
9
+
10
+ export default memo(() => {
11
+ const { t } = useTranslation('setting');
12
+ return (
13
+ <>
14
+ <PageTitle title={t('tab.agent')} />
15
+ <Agent />
16
+ </>
17
+ );
18
+ });
@@ -5,14 +5,11 @@ import { useTranslation } from 'react-i18next';
5
5
 
6
6
  import PageTitle from '@/components/PageTitle';
7
7
  import { CURRENT_VERSION } from '@/const/version';
8
- import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
9
- import { SettingsTabs } from '@/store/global/initialState';
10
8
 
11
9
  import Footer from '../features/Footer';
12
10
  import Common, { SettingsCommonProps } from './Common';
13
11
 
14
12
  export default memo<SettingsCommonProps>((props) => {
15
- useSwitchSideBarOnInit(SettingsTabs.Common);
16
13
  const { t } = useTranslation('setting');
17
14
 
18
15
  return (
@@ -1 +1,9 @@
1
- export { default } from '../layout.server';
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ import { SettingsTabs } from '@/store/global/initialState';
4
+
5
+ import SettingLayout from '../layout.server';
6
+
7
+ export default ({ children }: PropsWithChildren) => {
8
+ return <SettingLayout activeTab={SettingsTabs.Common}>{children}</SettingLayout>;
9
+ };