@lobehub/chat 0.70.1 → 0.70.3

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 (70) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/package.json +1 -1
  3. package/src/const/url.ts +4 -1
  4. package/src/features/MobileTabBar/index.tsx +4 -12
  5. package/src/features/SideBar/BottomActions.tsx +12 -2
  6. package/src/features/SideBar/TopActions.tsx +7 -1
  7. package/src/layout/AppMobileLayout.tsx +16 -8
  8. package/src/pages/chat/features/Conversation/Input/index.tsx +4 -3
  9. package/src/pages/chat/features/Conversation/index.tsx +5 -0
  10. package/src/pages/chat/features/Header/Mobile.tsx +1 -1
  11. package/src/pages/chat/features/Header/index.tsx +3 -4
  12. package/src/pages/chat/features/SessionList/Desktop.tsx +24 -0
  13. package/src/pages/chat/features/SessionList/{Header.tsx → Header/Desktop.tsx} +2 -26
  14. package/src/pages/chat/features/SessionList/Header/Mobile.tsx +42 -0
  15. package/src/pages/chat/features/SessionList/Header/index.tsx +14 -0
  16. package/src/pages/chat/features/SessionList/{Inbox.tsx → Inbox/index.tsx} +7 -2
  17. package/src/pages/chat/features/SessionList/List/index.tsx +8 -3
  18. package/src/pages/chat/features/SessionList/Mobile.tsx +26 -0
  19. package/src/pages/chat/features/SessionList/index.tsx +11 -25
  20. package/src/pages/chat/features/Sidebar/Desktop.tsx +58 -0
  21. package/src/pages/chat/features/Sidebar/{SystemRole.tsx → SystemRole/index.tsx} +3 -37
  22. package/src/pages/chat/features/Sidebar/SystemRole/style.ts +36 -0
  23. package/src/pages/chat/features/Sidebar/index.tsx +20 -78
  24. package/src/pages/chat/index.page.tsx +14 -13
  25. package/src/pages/chat/{mobile.tsx → layout.mobile.tsx} +2 -8
  26. package/src/pages/chat/layout.tsx +8 -17
  27. package/src/pages/chat/mobile/index.page.tsx +4 -7
  28. package/src/pages/chat/setting/features/Header/Desktop.tsx +21 -0
  29. package/src/pages/chat/setting/features/Header/Mobile.tsx +19 -0
  30. package/src/pages/chat/setting/features/Header/index.tsx +57 -0
  31. package/src/pages/chat/setting/index.page.tsx +5 -21
  32. package/src/pages/chat/setting/layout.mobile.tsx +18 -0
  33. package/src/pages/chat/setting/layout.tsx +22 -0
  34. package/src/pages/market/features/Header/Desktop.tsx +54 -0
  35. package/src/pages/market/features/Header/Mobile.tsx +42 -0
  36. package/src/pages/market/features/Header/index.tsx +13 -0
  37. package/src/pages/market/index.page.tsx +30 -0
  38. package/src/pages/market/layout.mobile.tsx +19 -0
  39. package/src/pages/market/layout.tsx +23 -0
  40. package/src/pages/settings/{Header.tsx → features/Header/Desktop.tsx} +2 -2
  41. package/src/pages/settings/features/Header/Mobile.tsx +18 -0
  42. package/src/pages/settings/features/Header/index.tsx +14 -0
  43. package/src/pages/settings/{Settings → features/Settings}/index.tsx +1 -2
  44. package/src/pages/settings/index.page.tsx +8 -21
  45. package/src/pages/settings/layout.mobile.tsx +18 -0
  46. package/src/pages/settings/layout.tsx +8 -1
  47. package/src/pages/welcome/{Banner → features/Banner}/AgentTemplate.tsx +1 -1
  48. package/src/pages/welcome/{Banner → features/Banner}/Hero.tsx +1 -1
  49. package/src/pages/welcome/{Banner → features/Banner}/index.tsx +1 -1
  50. package/src/pages/welcome/index.page.tsx +3 -3
  51. package/src/pages/welcome/layout.tsx +1 -1
  52. package/src/store/session/slices/session/action.ts +2 -2
  53. package/src/store/session/slices/session/initialState.ts +2 -0
  54. package/src/pages/chat/setting/Header.tsx +0 -82
  55. package/src/pages/chat/setting/mobile.tsx +0 -11
  56. package/src/pages/settings/mobile.tsx +0 -20
  57. /package/src/pages/chat/features/Header/{PC.tsx → Desktop.tsx} +0 -0
  58. /package/src/pages/chat/features/Header/{PluginTag.tsx → PluginTag/index.tsx} +0 -0
  59. /package/src/pages/chat/features/Header/{ShareButton.tsx → ShareButton/index.tsx} +0 -0
  60. /package/src/pages/chat/features/SessionList/{CollapseGroup.tsx → CollapseGroup/index.tsx} +0 -0
  61. /package/src/pages/chat/features/Sidebar/{Header.tsx → SystemRole/Header.tsx} +0 -0
  62. /package/src/pages/settings/{Settings → features/Settings}/Agent.tsx +0 -0
  63. /package/src/pages/settings/{Settings → features/Settings}/Common.tsx +0 -0
  64. /package/src/pages/settings/{ThemeSwatches → features/ThemeSwatches}/ThemeSwatchesNeutral.tsx +0 -0
  65. /package/src/pages/settings/{ThemeSwatches → features/ThemeSwatches}/ThemeSwatchesPrimary.tsx +0 -0
  66. /package/src/pages/settings/{ThemeSwatches → features/ThemeSwatches}/index.ts +0 -0
  67. /package/src/pages/welcome/{Banner → features/Banner}/AgentCard.tsx +0 -0
  68. /package/src/pages/welcome/{style.ts → features/Banner/style.ts} +0 -0
  69. /package/src/pages/welcome/{Footer → features/Footer}/index.tsx +0 -0
  70. /package/src/pages/welcome/{mobile.tsx → layout.mobile.tsx} +0 -0
@@ -0,0 +1,30 @@
1
+ import { useResponsive } from 'antd-style';
2
+ import Head from 'next/head';
3
+ import { memo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
7
+
8
+ import DesktopLayout from './layout';
9
+ import MobileLayout from './layout.mobile';
10
+
11
+ const Market = memo(() => {
12
+ const { t } = useTranslation('common');
13
+ const pageTitle = genSiteHeadTitle(t('tab.market'));
14
+ const { mobile } = useResponsive();
15
+
16
+ const RenderLayout = mobile ? MobileLayout : DesktopLayout;
17
+
18
+ return (
19
+ <>
20
+ <Head>
21
+ <title>{pageTitle}</title>
22
+ </Head>
23
+ <RenderLayout>
24
+ <h1>🤯 Coming Soon</h1>
25
+ </RenderLayout>
26
+ </>
27
+ );
28
+ });
29
+
30
+ export default Market;
@@ -0,0 +1,19 @@
1
+ import { ReactNode, memo } from 'react';
2
+ import { Center } from 'react-layout-kit';
3
+
4
+ import AppMobileLayout from '@/layout/AppMobileLayout';
5
+ import { useSwitchSideBarOnInit } from '@/store/global';
6
+
7
+ import Header from './features/Header';
8
+
9
+ const ChatMobileLayout = memo<{ children: ReactNode }>(({ children }) => {
10
+ useSwitchSideBarOnInit('chat');
11
+
12
+ return (
13
+ <AppMobileLayout navBar={<Header />} showTabBar>
14
+ <Center flex={1}>{children}</Center>
15
+ </AppMobileLayout>
16
+ );
17
+ });
18
+
19
+ export default ChatMobileLayout;
@@ -0,0 +1,23 @@
1
+ import { PropsWithChildren, memo } from 'react';
2
+ import { Center, Flexbox } from 'react-layout-kit';
3
+
4
+ import AppLayout from '../../layout/AppLayout';
5
+ import Header from './features/Header';
6
+
7
+ const MarketLayout = memo<PropsWithChildren>(({ children }) => {
8
+ return (
9
+ <AppLayout>
10
+ <Flexbox
11
+ flex={1}
12
+ height={'100vh'}
13
+ id={'lobe-market-container'}
14
+ style={{ position: 'relative' }}
15
+ >
16
+ <Header />
17
+ <Center flex={1}>{children}</Center>
18
+ </Flexbox>
19
+ </AppLayout>
20
+ );
21
+ });
22
+
23
+ export default MarketLayout;
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
 
5
5
  import { useSessionStore } from '@/store/session';
6
6
 
7
- const Header = memo(() => {
7
+ const Index = memo(() => {
8
8
  const { t } = useTranslation('setting');
9
9
  const [switchBackToChat] = useSessionStore((s) => [s.switchBackToChat]);
10
10
 
@@ -17,4 +17,4 @@ const Header = memo(() => {
17
17
  );
18
18
  });
19
19
 
20
- export default Header;
20
+ export default Index;
@@ -0,0 +1,18 @@
1
+ import { MobileNavBar, MobileNavBarTitle } from '@lobehub/ui';
2
+ import Router from 'next/router';
3
+ import { memo } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ const Header = memo(() => {
7
+ const { t } = useTranslation('setting');
8
+
9
+ return (
10
+ <MobileNavBar
11
+ center={<MobileNavBarTitle title={t('header.global')} />}
12
+ onBackClick={() => Router.push('/chat')}
13
+ showBackButton
14
+ />
15
+ );
16
+ });
17
+
18
+ export default Header;
@@ -0,0 +1,14 @@
1
+ import { useResponsive } from 'antd-style';
2
+ import { memo } from 'react';
3
+
4
+ import Desktop from './Desktop';
5
+ import Mobile from './Mobile';
6
+
7
+ const Header = memo(() => {
8
+ const { mobile } = useResponsive();
9
+ const Render = mobile ? Mobile : Desktop;
10
+
11
+ return <Render />;
12
+ });
13
+
14
+ export default Header;
@@ -6,8 +6,7 @@ import { memo, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Center, Flexbox } from 'react-layout-kit';
8
8
 
9
- import pkg from '@/../package.json';
10
-
9
+ import pkg from '../../../../../package.json';
11
10
  import Agent from './Agent';
12
11
  import Common from './Common';
13
12
 
@@ -2,17 +2,14 @@ import { useResponsive } from 'antd-style';
2
2
  import Head from 'next/head';
3
3
  import { memo } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { Flexbox } from 'react-layout-kit';
6
5
 
7
- import SafeSpacing from '@/components/SafeSpacing';
8
6
  import { createI18nNext } from '@/locales/create';
9
7
  import { useOnFinishHydrationGlobal, useSwitchSideBarOnInit } from '@/store/global';
10
8
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
11
9
 
12
- import Header from './Header';
13
- import Settings from './Settings';
14
- import SettingLayout from './layout';
15
- import Mobile from './mobile';
10
+ import Settings from './features/Settings';
11
+ import DesktopLayout from './layout';
12
+ import MobileLayout from './layout.mobile';
16
13
 
17
14
  const initI18n = createI18nNext({ namespace: 'setting' });
18
15
 
@@ -21,6 +18,8 @@ const Setting = memo(() => {
21
18
  const { t } = useTranslation('setting');
22
19
  const pageTitle = genSiteHeadTitle(t('header.global'));
23
20
 
21
+ const RenderLayout = mobile ? MobileLayout : DesktopLayout;
22
+
24
23
  useSwitchSideBarOnInit('settings');
25
24
 
26
25
  useOnFinishHydrationGlobal(() => {
@@ -32,21 +31,9 @@ const Setting = memo(() => {
32
31
  <Head>
33
32
  <title>{pageTitle}</title>
34
33
  </Head>
35
- {mobile ? (
36
- <Mobile>
37
- <Flexbox align={'center'} padding={16} style={{ overflow: 'auto' }}>
38
- <Settings />
39
- </Flexbox>
40
- </Mobile>
41
- ) : (
42
- <SettingLayout>
43
- <Header />
44
- <Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
45
- <SafeSpacing />
46
- <Settings />
47
- </Flexbox>
48
- </SettingLayout>
49
- )}
34
+ <RenderLayout>
35
+ <Settings />
36
+ </RenderLayout>
50
37
  </>
51
38
  );
52
39
  });
@@ -0,0 +1,18 @@
1
+ import { ReactNode, memo } from 'react';
2
+ import { Flexbox } from 'react-layout-kit';
3
+
4
+ import AppMobileLayout from '@/layout/AppMobileLayout';
5
+
6
+ import Header from './features/Header';
7
+
8
+ const SettingLayout = memo<{ children: ReactNode }>(({ children }) => {
9
+ return (
10
+ <AppMobileLayout navBar={<Header />}>
11
+ <Flexbox align={'center'} padding={16} style={{ overflow: 'auto' }}>
12
+ {children}
13
+ </Flexbox>
14
+ </AppMobileLayout>
15
+ );
16
+ });
17
+
18
+ export default SettingLayout;
@@ -1,13 +1,20 @@
1
1
  import { ReactNode, memo } from 'react';
2
2
  import { Flexbox } from 'react-layout-kit';
3
3
 
4
+ import SafeSpacing from '@/components/SafeSpacing';
4
5
  import AppLayout from '@/layout/AppLayout';
5
6
 
7
+ import Header from './features/Header';
8
+
6
9
  const SettingLayout = memo<{ children: ReactNode }>(({ children }) => {
7
10
  return (
8
11
  <AppLayout>
9
12
  <Flexbox flex={1} height={'100vh'} style={{ position: 'relative' }}>
10
- {children}
13
+ <Header />
14
+ <Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
15
+ <SafeSpacing />
16
+ {children}
17
+ </Flexbox>
11
18
  </Flexbox>
12
19
  </AppLayout>
13
20
  );
@@ -2,8 +2,8 @@ import { useResponsive } from 'antd-style';
2
2
  import { memo } from 'react';
3
3
  import { Flexbox } from 'react-layout-kit';
4
4
 
5
- import { useStyles } from '../style';
6
5
  import AgentCard, { type AgentCardProps } from './AgentCard';
6
+ import { useStyles } from './style';
7
7
 
8
8
  const items: AgentCardProps['meta'][] = [
9
9
  {
@@ -3,7 +3,7 @@ import { useResponsive } from 'antd-style';
3
3
  import { memo, useMemo } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
- import { genSize, useStyles } from '../style';
6
+ import { genSize, useStyles } from './style';
7
7
 
8
8
  const Hero = memo<{ width: number }>(({ width }) => {
9
9
  const size = useMemo(
@@ -11,8 +11,8 @@ import { SESSION_CHAT_URL } from '@/const/url';
11
11
  import { useImportConfig } from '@/hooks/useImportConfig';
12
12
  import { useSessionStore } from '@/store/session';
13
13
 
14
- import { useStyles } from '../style';
15
14
  import Hero from './Hero';
15
+ import { useStyles } from './style';
16
16
 
17
17
  const Banner = memo<{ mobile?: boolean }>(() => {
18
18
  const { importConfig } = useImportConfig();
@@ -5,10 +5,10 @@ import { useTranslation } from 'react-i18next';
5
5
 
6
6
  import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
7
7
 
8
- import Banner from './Banner';
9
- import Footer from './Footer';
8
+ import Banner from './features/Banner';
9
+ import Footer from './features/Footer';
10
10
  import Layout from './layout';
11
- import Mobile from './mobile';
11
+ import Mobile from './layout.mobile';
12
12
 
13
13
  const Welcome = memo(() => {
14
14
  const { mobile } = useResponsive();
@@ -4,7 +4,7 @@ import { PropsWithChildren, memo } from 'react';
4
4
  import { Center, Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import AppLayout from '../../layout/AppLayout';
7
- import { useStyles } from './style';
7
+ import { useStyles } from './features/Banner/style';
8
8
 
9
9
  const WelcomeLayout = memo<PropsWithChildren>(({ children }) => {
10
10
  const { styles } = useStyles();
@@ -158,13 +158,13 @@ export const createSessionSlice: StateCreator<
158
158
 
159
159
  get().activeSession(id);
160
160
 
161
- Router.push(SESSION_CHAT_URL(id));
161
+ Router.push(SESSION_CHAT_URL(id, get().isMobile));
162
162
  },
163
163
  switchSession: (sessionId = INBOX_SESSION_ID) => {
164
164
  if (get().activeId === sessionId) return;
165
165
 
166
166
  get().activeSession(sessionId);
167
167
 
168
- Router.push(SESSION_CHAT_URL(sessionId));
168
+ Router.push(SESSION_CHAT_URL(sessionId, get().isMobile));
169
169
  },
170
170
  });
@@ -13,6 +13,7 @@ export interface SessionState {
13
13
  activeId: string | undefined;
14
14
  // 默认会话
15
15
  inbox: LobeAgentSession;
16
+ isMobile?: boolean;
16
17
  searchKeywords: string;
17
18
  sessions: Record<string, LobeAgentSession>;
18
19
  }
@@ -40,6 +41,7 @@ export const initInbox = merge({}, initLobeSession, {
40
41
  export const initialSessionState: SessionState = {
41
42
  activeId: undefined,
42
43
  inbox: initInbox,
44
+ isMobile: false,
43
45
  searchKeywords: '',
44
46
  sessions: {},
45
47
  };
@@ -1,82 +0,0 @@
1
- import {
2
- ActionIcon,
3
- ChatHeader,
4
- ChatHeaderTitle,
5
- MobileNavBar,
6
- MobileNavBarTitle,
7
- } from '@lobehub/ui';
8
- import { Dropdown, MenuProps } from 'antd';
9
- import { HardDriveDownload, Share2 } from 'lucide-react';
10
- import { memo, useMemo } from 'react';
11
- import { useTranslation } from 'react-i18next';
12
-
13
- import { exportSingleAgent, exportSingleSession } from '@/helpers/export';
14
- import { useSessionStore } from '@/store/session';
15
-
16
- const Header = memo<{ mobile?: boolean }>(({ mobile }) => {
17
- const { t } = useTranslation('setting');
18
- const [id, onBack] = useSessionStore((s) => [s.activeId, s.switchBackToChat]);
19
-
20
- const items = useMemo<MenuProps['items']>(
21
- () => [
22
- {
23
- key: 'agent',
24
- label: <div>{t('exportType.agent', { ns: 'common' })}</div>,
25
- onClick: () => {
26
- if (!id) return;
27
-
28
- exportSingleAgent(id);
29
- },
30
- },
31
- {
32
- key: 'agentWithMessage',
33
- label: <div>{t('exportType.agentWithMessage', { ns: 'common' })}</div>,
34
- onClick: () => {
35
- if (!id) return;
36
-
37
- exportSingleSession(id);
38
- },
39
- },
40
- ],
41
- [],
42
- );
43
-
44
- if (mobile)
45
- return (
46
- <MobileNavBar
47
- center={<MobileNavBarTitle title={t('header.session')} />}
48
- onBackClick={onBack}
49
- right={
50
- <>
51
- <ActionIcon icon={Share2} title={t('share', { ns: 'common' })} />
52
- <Dropdown arrow={false} menu={{ items }} trigger={['click']}>
53
- <ActionIcon icon={HardDriveDownload} title={t('export', { ns: 'common' })} />
54
- </Dropdown>
55
- </>
56
- }
57
- showBackButton
58
- />
59
- );
60
-
61
- return (
62
- <ChatHeader
63
- left={<ChatHeaderTitle title={t('header.session')} />}
64
- onBackClick={onBack}
65
- right={
66
- <>
67
- <ActionIcon icon={Share2} size={{ fontSize: 24 }} title={t('share', { ns: 'common' })} />
68
- <Dropdown arrow={false} menu={{ items }} trigger={['click']}>
69
- <ActionIcon
70
- icon={HardDriveDownload}
71
- size={{ fontSize: 24 }}
72
- title={t('export', { ns: 'common' })}
73
- />
74
- </Dropdown>
75
- </>
76
- }
77
- showBackButton
78
- />
79
- );
80
- });
81
-
82
- export default Header;
@@ -1,11 +0,0 @@
1
- import { PropsWithChildren, memo } from 'react';
2
-
3
- import AppMobileLayout from '@/layout/AppMobileLayout';
4
-
5
- import Header from './Header';
6
-
7
- const MobileLayout = memo<PropsWithChildren>(({ children }) => {
8
- return <AppMobileLayout navBar={<Header mobile />}>{children}</AppMobileLayout>;
9
- });
10
-
11
- export default MobileLayout;
@@ -1,20 +0,0 @@
1
- import { MobileNavBar, MobileNavBarTitle } from '@lobehub/ui';
2
- import { ReactNode, memo } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
-
5
- import AppMobileLayout from '@/layout/AppMobileLayout';
6
-
7
- const SettingLayout = memo<{ children: ReactNode }>(({ children }) => {
8
- const { t } = useTranslation('setting');
9
-
10
- return (
11
- <AppMobileLayout
12
- navBar={<MobileNavBar center={<MobileNavBarTitle title={t('header.global')} />} />}
13
- showTabBar
14
- >
15
- {children}
16
- </AppMobileLayout>
17
- );
18
- });
19
-
20
- export default SettingLayout;