@lobehub/chat 0.127.0 → 0.127.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 +25 -0
- package/package.json +1 -1
- package/src/app/chat/features/ChatHeader/SettingButton.tsx +1 -2
- package/src/app/settings/(desktop)/features/Header.tsx +3 -4
- package/src/app/settings/(desktop)/features/SideBar.tsx +42 -0
- package/src/app/settings/(desktop)/index.tsx +4 -3
- package/src/app/settings/(desktop)/layout.desktop.tsx +14 -6
- package/src/app/settings/(desktop)/layout.responsive.tsx +4 -4
- package/src/app/settings/(mobile)/features/ExtraList.tsx +7 -5
- package/src/app/settings/(mobile)/features/Header/index.tsx +8 -5
- package/src/app/settings/(mobile)/index.tsx +1 -3
- package/src/app/settings/(mobile)/layout.mobile.tsx +8 -4
- package/src/app/settings/(mobile)/mobile/index.tsx +3 -5
- package/src/app/settings/agent/Agent.tsx +0 -4
- package/src/app/settings/agent/layout.tsx +9 -1
- package/src/app/settings/agent/page.tsx +17 -2
- package/src/app/settings/common/index.tsx +0 -3
- package/src/app/settings/common/layout.tsx +9 -1
- package/src/app/settings/features/SettingList/Item.tsx +50 -0
- package/src/app/settings/features/{SideBar/List.tsx → SettingList/index.tsx} +14 -15
- package/src/app/settings/layout.server.tsx +10 -3
- package/src/app/settings/llm/Azure/index.tsx +78 -106
- package/src/app/settings/llm/Bedrock/index.tsx +60 -89
- package/src/app/settings/llm/Google/index.tsx +26 -55
- package/src/app/settings/llm/Moonshot/index.tsx +29 -54
- package/src/app/settings/llm/Ollama/index.tsx +35 -61
- package/src/app/settings/llm/OpenAI/index.tsx +91 -107
- package/src/app/settings/llm/Zhipu/index.tsx +29 -54
- package/src/app/settings/llm/components/ProviderConfig/index.tsx +58 -0
- package/src/app/settings/llm/index.tsx +42 -0
- package/src/app/settings/llm/layout.tsx +9 -1
- package/src/app/settings/llm/page.tsx +6 -46
- package/src/app/settings/tts/layout.tsx +9 -1
- package/src/app/settings/tts/page.tsx +17 -2
- package/src/const/settings.ts +1 -0
- package/src/features/SideBar/BottomActions.tsx +1 -2
- package/src/layout/ResponsiveLayout.client.tsx +7 -7
- package/src/layout/ResponsiveLayout.server.tsx +6 -6
- package/src/services/_auth.test.ts +132 -0
- package/src/services/_auth.ts +1 -1
- package/src/store/global/slices/common/initialState.ts +0 -2
- package/src/store/global/slices/settings/action.test.ts +0 -13
- package/src/store/global/slices/settings/action.ts +0 -5
- package/src/store/global/slices/settings/selectors/modelProvider.ts +7 -0
- package/src/types/settings/modelProvider.ts +1 -0
- package/src/app/settings/agent/index.tsx +0 -21
- package/src/app/settings/features/SideBar/Item.tsx +0 -44
- package/src/app/settings/features/SideBar/index.tsx +0 -42
- package/src/app/settings/tts/index.tsx +0 -21
- package/src/store/global/hooks/useSwitchSettingsOnInit.ts +0 -12
- /package/src/app/settings/llm/{Checker.tsx → components/Checker.tsx} +0 -0
- /package/src/app/settings/llm/{useSyncSettings.ts → components/ProviderConfig/useSyncSettings.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.127.1](https://github.com/lobehub/lobe-chat/compare/v0.127.0...v0.127.1)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-02-14**</sup>
|
|
8
|
+
|
|
9
|
+
#### 💄 Styles
|
|
10
|
+
|
|
11
|
+
- **misc**: Improve settings tabs style and refactor the LLM setting page.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Styles
|
|
19
|
+
|
|
20
|
+
- **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))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## [Version 0.127.0](https://github.com/lobehub/lobe-chat/compare/v0.126.5...v0.127.0)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-02-13**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.127.
|
|
3
|
+
"version": "0.127.1",
|
|
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",
|
|
@@ -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 {
|
|
9
|
+
import { SidebarTabKey } from '@/store/global/slices/common/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');
|
|
@@ -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 {
|
|
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.${
|
|
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
|
|
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
|
-
<
|
|
17
|
+
<DesktopLayout activeTab={SettingsTabs.Common}>
|
|
17
18
|
<Common {...props} />
|
|
18
|
-
</
|
|
19
|
+
</DesktopLayout>
|
|
19
20
|
</ResponsiveIndex>
|
|
20
21
|
));
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
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
8
|
import { useSwitchSideBarOnInit } from '@/store/global';
|
|
9
|
-
import { SidebarTabKey } from '@/store/global/initialState';
|
|
9
|
+
import { SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
|
|
10
10
|
|
|
11
|
-
import SideBar from '../features/SideBar';
|
|
12
11
|
import Header from './features/Header';
|
|
12
|
+
import SideBar from './features/SideBar';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export interface DesktopLayoutProps {
|
|
15
|
+
activeTab: SettingsTabs;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DesktopLayout = memo<DesktopLayoutProps>(({ children, activeTab }) => {
|
|
15
20
|
useSwitchSideBarOnInit(SidebarTabKey.Setting);
|
|
21
|
+
|
|
16
22
|
return (
|
|
17
23
|
<AppLayoutDesktop>
|
|
18
|
-
<SideBar />
|
|
24
|
+
<SideBar activeTab={activeTab} />
|
|
19
25
|
<Flexbox flex={1} height={'100%'} style={{ position: 'relative' }}>
|
|
20
|
-
<Header />
|
|
26
|
+
<Header activeTab={activeTab} />
|
|
21
27
|
<Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
|
|
22
28
|
<SafeSpacing />
|
|
23
29
|
<Center gap={16} width={'100%'}>
|
|
@@ -28,3 +34,5 @@ export default memo(({ children }: PropsWithChildren) => {
|
|
|
28
34
|
</AppLayoutDesktop>
|
|
29
35
|
);
|
|
30
36
|
});
|
|
37
|
+
|
|
38
|
+
export default DesktopLayout;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import dynamic from 'next/dynamic';
|
|
4
|
-
import { FC,
|
|
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 }
|
|
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 {
|
|
10
|
+
import { SettingsTabs } from '@/store/global/initialState';
|
|
11
11
|
|
|
12
|
-
import Item from '../../features/
|
|
12
|
+
import Item from '../../features/SettingList/Item';
|
|
13
13
|
|
|
14
|
-
|
|
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 :
|
|
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 {
|
|
6
|
+
import { SettingsTabs } from '@/store/global/initialState';
|
|
7
7
|
|
|
8
|
-
|
|
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.${
|
|
17
|
-
onBackClick={() => router.
|
|
19
|
+
center={<MobileNavBarTitle title={t(`tab.${activeTab}`)} />}
|
|
20
|
+
onBackClick={() => router.push('/settings')}
|
|
18
21
|
showBackButton
|
|
19
22
|
/>
|
|
20
23
|
);
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
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
7
|
import { useSwitchSideBarOnInit } from '@/store/global';
|
|
8
|
-
import { SidebarTabKey } from '@/store/global/initialState';
|
|
8
|
+
import { SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
|
|
9
9
|
|
|
10
10
|
import Header from './features/Header';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export interface SettingLayoutProps {
|
|
13
|
+
activeTab: SettingsTabs;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export default memo(({ children, activeTab }: SettingLayoutProps) => {
|
|
13
17
|
useSwitchSideBarOnInit(SidebarTabKey.Setting);
|
|
14
18
|
return (
|
|
15
|
-
<AppLayoutMobile navBar={<Header />}>
|
|
19
|
+
<AppLayoutMobile navBar={<Header activeTab={activeTab} />}>
|
|
16
20
|
<Flexbox style={{ overflow: 'auto' }}>{children}</Flexbox>
|
|
17
21
|
</AppLayoutMobile>
|
|
18
22
|
);
|
|
@@ -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
|
|
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
|
|
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
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Icon, List } from '@lobehub/ui';
|
|
2
|
+
import { createStyles, useResponsive } from 'antd-style';
|
|
3
|
+
import { ChevronRight, type LucideIcon } from 'lucide-react';
|
|
4
|
+
import { CSSProperties, ReactNode, memo } from 'react';
|
|
5
|
+
|
|
6
|
+
const { Item } = List;
|
|
7
|
+
|
|
8
|
+
const useStyles = createStyles(({ css, token, responsive }) => ({
|
|
9
|
+
container: css`
|
|
10
|
+
position: relative;
|
|
11
|
+
padding-top: 16px;
|
|
12
|
+
padding-bottom: 16px;
|
|
13
|
+
border-radius: ${token.borderRadius}px;
|
|
14
|
+
${responsive.mobile} {
|
|
15
|
+
border-radius: 0;
|
|
16
|
+
}
|
|
17
|
+
`,
|
|
18
|
+
noHover: css`
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
`,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
export interface ItemProps {
|
|
24
|
+
active?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
hoverable?: boolean;
|
|
27
|
+
icon: LucideIcon;
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const SettingItem = memo<ItemProps>(
|
|
33
|
+
({ label, icon, hoverable = true, active = false, style, className }) => {
|
|
34
|
+
const { cx, styles } = useStyles();
|
|
35
|
+
const { mobile } = useResponsive();
|
|
36
|
+
return (
|
|
37
|
+
<Item
|
|
38
|
+
active={active}
|
|
39
|
+
avatar={<Icon icon={icon} size={{ fontSize: 20 }} />}
|
|
40
|
+
className={cx(styles.container, !hoverable && styles.noHover, className)}
|
|
41
|
+
style={style}
|
|
42
|
+
title={label as string}
|
|
43
|
+
>
|
|
44
|
+
{mobile && <Icon icon={ChevronRight} size={{ fontSize: 16 }} />}
|
|
45
|
+
</Item>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export default SettingItem;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { useResponsive } from 'antd-style';
|
|
2
1
|
import { Bot, Mic2, Settings2, Webhook } from 'lucide-react';
|
|
3
2
|
import Link from 'next/link';
|
|
4
3
|
import { memo } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
|
|
7
|
-
import { useGlobalStore } from '@/store/global';
|
|
8
6
|
import { SettingsTabs } from '@/store/global/initialState';
|
|
9
7
|
|
|
10
8
|
import Item from './Item';
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export interface SettingListProps {
|
|
11
|
+
activeTab?: SettingsTabs;
|
|
12
|
+
mobile?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SettingList = memo<SettingListProps>(({ activeTab, mobile }) => {
|
|
13
16
|
const { t } = useTranslation('setting');
|
|
14
|
-
const [tab, switchSettingTabs] = useGlobalStore((s) => [s.settingsTab, s.switchSettingTabs]);
|
|
15
|
-
const { mobile } = useResponsive();
|
|
16
17
|
|
|
17
18
|
const items = [
|
|
18
19
|
{ icon: Settings2, label: t('tab.common'), value: SettingsTabs.Common },
|
|
@@ -22,17 +23,15 @@ const List = memo(() => {
|
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
return items.map(({ value, icon, label }) => (
|
|
25
|
-
<Link
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
>
|
|
33
|
-
<Item active={mobile ? false : tab === value} icon={icon} label={label} />
|
|
26
|
+
<Link aria-label={label} href={`/settings/${value}`} key={value}>
|
|
27
|
+
<Item
|
|
28
|
+
active={mobile ? false : activeTab === value}
|
|
29
|
+
hoverable={!mobile}
|
|
30
|
+
icon={icon}
|
|
31
|
+
label={label}
|
|
32
|
+
/>
|
|
34
33
|
</Link>
|
|
35
34
|
));
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
export default
|
|
37
|
+
export default SettingList;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { PropsWithChildren, memo } from 'react';
|
|
1
|
+
import { PropsWithChildren, ReactNode, memo } from 'react';
|
|
2
2
|
|
|
3
3
|
import ResponsiveLayout from '@/layout/ResponsiveLayout.server';
|
|
4
|
+
import { SettingsTabs } from '@/store/global/initialState';
|
|
4
5
|
|
|
5
6
|
import DesktopLayout from './(desktop)/layout.responsive';
|
|
6
7
|
import MobileLayout from './(mobile)/layout.mobile';
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
-
|
|
9
|
+
export interface SettingLayoutProps {
|
|
10
|
+
activeTab: SettingsTabs;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
const SettingLayout = memo<SettingLayoutProps>(({ children, ...res }: PropsWithChildren) => (
|
|
14
|
+
<ResponsiveLayout Desktop={DesktopLayout} Mobile={MobileLayout} {...res}>
|
|
10
15
|
{children}
|
|
11
16
|
</ResponsiveLayout>
|
|
12
17
|
));
|
|
18
|
+
|
|
19
|
+
export default SettingLayout;
|