@lobehub/chat 0.70.1 → 0.70.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.70.2](https://github.com/lobehub/lobe-chat/compare/v0.70.1...v0.70.2)
6
+
7
+ <sup>Released on **2023-09-08**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: 修正移动端路由问题.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: 修正移动端路由问题 ([ae3d2f4](https://github.com/lobehub/lobe-chat/commit/ae3d2f4))
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 0.70.1](https://github.com/lobehub/lobe-chat/compare/v0.70.0...v0.70.1)
6
31
 
7
32
  <sup>Released on **2023-09-08**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.70.1",
3
+ "version": "0.70.2",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
package/src/const/url.ts CHANGED
@@ -10,4 +10,5 @@ export const DISCORD = 'https://discord.gg/AYFPHvv2jT';
10
10
  export const PLUGINS_INDEX_URL =
11
11
  process.env.PLUGINS_INDEX_URL ?? 'https://chat-plugins.lobehub.com';
12
12
 
13
- export const SESSION_CHAT_URL = (id: string = INBOX_SESSION_ID) => `/chat#session=${id}`;
13
+ export const SESSION_CHAT_URL = (id: string = INBOX_SESSION_ID, mobile?: boolean) =>
14
+ mobile ? `/chat/mobile#session=${id}` : `/chat#session=${id}`;
@@ -6,6 +6,7 @@ import { Flexbox } from 'react-layout-kit';
6
6
 
7
7
  import SafeSpacing from '@/components/SafeSpacing';
8
8
  import MobileTabBar from '@/features/MobileTabBar';
9
+ import { useOnFinishHydrationSession, useSessionStore } from '@/store/session';
9
10
 
10
11
  const useStyles = createStyles(({ css }) => ({
11
12
  container: css`
@@ -45,6 +46,10 @@ const AppMobileLayout = memo<AppMobileLayoutProps>(
45
46
  ({ children, showTabBar, navBar, style, className }) => {
46
47
  const { styles, cx } = useStyles();
47
48
 
49
+ useOnFinishHydrationSession(() => {
50
+ useSessionStore.setState({ isMobile: true });
51
+ }, []);
52
+
48
53
  return (
49
54
  <>
50
55
  <Head>
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import SafeSpacing from '@/components/SafeSpacing';
7
+ import { usePluginStore } from '@/store/plugin';
7
8
 
8
9
  import ChatList from './ChatList';
9
10
  import ChatInput from './Input';
@@ -12,6 +13,10 @@ import ChatScrollAnchor from './ScrollAnchor';
12
13
  const Conversation = memo<{ mobile?: boolean }>(({ mobile }) => {
13
14
  const ref = useRef(null);
14
15
  const { t } = useTranslation('common');
16
+
17
+ const useFetchPluginList = usePluginStore((s) => s.useFetchPluginList);
18
+ useFetchPluginList();
19
+
15
20
  return (
16
21
  <Flexbox flex={1} style={{ position: 'relative' }}>
17
22
  <div style={{ flex: 1, overflow: 'hidden', position: 'relative' }}>
@@ -15,7 +15,12 @@ const Inbox = memo(() => {
15
15
  const ref = useRef(null);
16
16
  const isHovering = useHover(ref);
17
17
  const { t } = useTranslation('common');
18
- const [activeId, switchSession] = useSessionStore((s) => [s.activeId, s.switchSession]);
18
+
19
+ const [mobile, activeId, switchSession] = useSessionStore((s) => [
20
+ s.isMobile,
21
+ s.activeId,
22
+ s.switchSession,
23
+ ]);
19
24
 
20
25
  const avatarRender = useMemo(
21
26
  () => (
@@ -31,7 +36,7 @@ const Inbox = memo(() => {
31
36
 
32
37
  return (
33
38
  <Link
34
- href={SESSION_CHAT_URL()}
39
+ href={SESSION_CHAT_URL(INBOX_SESSION_ID, mobile)}
35
40
  onClick={(e) => {
36
41
  e.preventDefault();
37
42
  switchSession(INBOX_SESSION_ID);
@@ -1,3 +1,4 @@
1
+ import { useResponsive } from 'antd-style';
1
2
  import isEqual from 'fast-deep-equal';
2
3
  import Link from 'next/link';
3
4
  import { memo } from 'react';
@@ -12,20 +13,24 @@ import SkeletonList from './SkeletonList';
12
13
 
13
14
  const SessionList = memo(() => {
14
15
  const list = useSessionStore(sessionSelectors.sessionList, isEqual);
15
- const activeSession = useSessionStore((s) => s.activeSession);
16
+ const [activeSession, switchSession] = useSessionStore((s) => [s.activeSession, s.switchSession]);
16
17
 
17
18
  const isInit = useSessionHydrated();
18
19
 
20
+ const { mobile } = useResponsive();
21
+
19
22
  return !isInit ? (
20
23
  <SkeletonList />
21
24
  ) : list.length > 0 ? (
22
25
  list.map(({ id }) => (
23
26
  <Link
24
- href={SESSION_CHAT_URL(id)}
27
+ href={SESSION_CHAT_URL(id, mobile)}
25
28
  key={id}
26
29
  onClick={(e) => {
27
30
  e.preventDefault();
28
- activeSession(id);
31
+
32
+ if (mobile) switchSession(id);
33
+ else activeSession(id);
29
34
  }}
30
35
  >
31
36
  <SessionItem id={id} />
@@ -4,7 +4,6 @@ import { Flexbox } from 'react-layout-kit';
4
4
 
5
5
  import AppLayout from '@/layout/AppLayout';
6
6
  import { useSwitchSideBarOnInit } from '@/store/global';
7
- import { usePluginStore } from '@/store/plugin';
8
7
 
9
8
  import { Sessions } from './features/SessionList';
10
9
 
@@ -13,9 +12,6 @@ const ChatLayout = memo<PropsWithChildren>(({ children }) => {
13
12
 
14
13
  useSwitchSideBarOnInit('chat');
15
14
 
16
- const useFetchPluginList = usePluginStore((s) => s.useFetchPluginList);
17
- useFetchPluginList();
18
-
19
15
  return (
20
16
  <AppLayout>
21
17
  <Sessions />
@@ -10,7 +10,6 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
10
10
 
11
11
  import Conversation from '../features/Conversation';
12
12
  import SideBar from '../features/Sidebar';
13
- import ChatLayout from '../layout';
14
13
 
15
14
  const Chat = memo(() => {
16
15
  const [avatar, title] = useSessionStore((s) => [
@@ -26,12 +25,10 @@ const Chat = memo(() => {
26
25
  <title>{pageTitle}</title>
27
26
  </Head>
28
27
  <AppMobileLayout navBar={<Header />}>
29
- <ChatLayout>
30
- <Flexbox height={'calc(100vh - 44px)'} horizontal>
31
- <Conversation mobile />
32
- <SideBar mobile />
33
- </Flexbox>
34
- </ChatLayout>
28
+ <Flexbox height={'calc(100vh - 44px)'} horizontal>
29
+ <Conversation mobile />
30
+ <SideBar mobile />
31
+ </Flexbox>
35
32
  </AppMobileLayout>
36
33
  </>
37
34
  );
@@ -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
  };