From 62489ef12f045feb7c97a6314e276c84935152e4 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Tue, 27 Jun 2023 21:00:15 +0800 Subject: [PATCH] fix: share chat --- client/src/components/Layout/index.tsx | 35 +++++++++++--------- client/src/components/Layout/navbarPhone.tsx | 9 ++++- client/src/pages/chat/share.tsx | 7 ++-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/client/src/components/Layout/index.tsx b/client/src/components/Layout/index.tsx index b29e6954a..4978591e1 100644 --- a/client/src/components/Layout/index.tsx +++ b/client/src/components/Layout/index.tsx @@ -51,7 +51,7 @@ const Layout = ({ children }: { children: JSX.Element }) => { return () => { window.removeEventListener('resize', resize); }; - }, [setScreenWidth]); + }, []); const { data: unread = 0 } = useQuery(['getUnreadCount'], getUnreadCount, { enabled: !!userInfo, @@ -64,8 +64,8 @@ const Layout = ({ children }: { children: JSX.Element }) => { h={'100%'} bgGradient={'linear(to-t,rgba(173, 206, 255, 0.05) 0%, rgba(173, 206, 255, 0.12) 100%)'} > - {isPc ? ( - pcUnShowLayoutRoute[router.pathname] ? ( + + {pcUnShowLayoutRoute[router.pathname] ? ( {children} ) : ( <> @@ -76,19 +76,22 @@ const Layout = ({ children }: { children: JSX.Element }) => { {children} - ) - ) : phoneUnShowLayoutRoute[router.pathname] || isChatPage ? ( - {children} - ) : ( - - - {children} - - - - - - )} + )} + + + {phoneUnShowLayoutRoute[router.pathname] || isChatPage ? ( + {children} + ) : ( + + + {children} + + + + + + )} + diff --git a/client/src/components/Layout/navbarPhone.tsx b/client/src/components/Layout/navbarPhone.tsx index 26b8d482a..c6fe40194 100644 --- a/client/src/components/Layout/navbarPhone.tsx +++ b/client/src/components/Layout/navbarPhone.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { useRouter } from 'next/router'; import MyIcon from '../Icon'; -import { Flex } from '@chakra-ui/react'; +import { Flex, Box } from '@chakra-ui/react'; import { useChatStore } from '@/store/chat'; import Badge from '../Badge'; @@ -11,24 +11,28 @@ const NavbarPhone = ({ unread }: { unread: number }) => { const navbarList = useMemo( () => [ { + label: '聊天', icon: 'tabbarChat', link: `/chat?modelId=${lastChatModelId}&chatId=${lastChatId}`, activeLink: ['/chat'], unread: 0 }, { + label: '应用', icon: 'tabbarModel', link: `/model`, activeLink: ['/model'], unread: 0 }, { + label: '工具', icon: 'tabbarMore', link: '/tools', activeLink: ['/tools'], unread: 0 }, { + label: '我的', icon: 'tabbarMe', link: '/number', activeLink: ['/number'], @@ -57,7 +61,9 @@ const NavbarPhone = ({ unread }: { unread: number }) => { textAlign={'center'} alignItems={'center'} h={'100%'} + pt={1} px={3} + transform={'scale(0.9)'} {...(item.activeLink.includes(router.asPath) ? { color: '#7089f1' @@ -89,6 +95,7 @@ const NavbarPhone = ({ unread }: { unread: number }) => { > + {item.label} ))} diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx index a7d98e39f..10b89cf33 100644 --- a/client/src/pages/chat/share.tsx +++ b/client/src/pages/chat/share.tsx @@ -62,7 +62,7 @@ const textareaMinH = '22px'; const Chat = () => { const router = useRouter(); - const { shareId = '', historyId = '' } = router.query as { shareId: string; historyId: string }; + const { shareId = '', historyId } = router.query as { shareId: string; historyId: string }; const theme = useTheme(); const ChatBox = useRef(null); @@ -491,14 +491,13 @@ const Chat = () => { ]); // 初始化聊天框 - useQuery(['init', historyId], () => { + useQuery(['init', shareId, historyId], () => { if (!shareId) { return null; } if (!historyId) { - router.replace(`/chat/share?shareId=${shareId}&historyId=${new Types.ObjectId()}`); - return null; + return router.replace(`/chat/share?shareId=${shareId}&historyId=${new Types.ObjectId()}`); } return loadChatInfo();