From 95066262b76b2555632bbbda523743418dfc7135 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Mon, 26 Jun 2023 15:05:34 +0800 Subject: [PATCH] close ssr query --- client/src/pages/chat/index.tsx | 10 ++-------- client/src/pages/chat/share.tsx | 10 ++-------- client/src/pages/index.tsx | 6 ++++-- client/src/pages/kb/index.tsx | 9 ++------- client/src/pages/model/index.tsx | 9 ++------- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx index 3baf7de18..28529bcc1 100644 --- a/client/src/pages/chat/index.tsx +++ b/client/src/pages/chat/index.tsx @@ -63,8 +63,9 @@ import { adaptChatItem_openAI } from '@/utils/plugin/openai'; const textareaMinH = '22px'; -const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => { +const Chat = () => { const router = useRouter(); + const { modelId = '', chatId = '' } = router.query as { modelId: string; chatId: string }; const theme = useTheme(); const ChatBox = useRef(null); @@ -950,11 +951,4 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => { ); }; -Chat.getInitialProps = ({ query, req }: any) => { - return { - modelId: query?.modelId || '', - chatId: query?.chatId || '' - }; -}; - export default Chat; diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx index 7ae3d21fa..a7d98e39f 100644 --- a/client/src/pages/chat/share.tsx +++ b/client/src/pages/chat/share.tsx @@ -60,8 +60,9 @@ import { adaptChatItem_openAI } from '@/utils/plugin/openai'; const textareaMinH = '22px'; -const Chat = ({ shareId, historyId }: { shareId: string; historyId: string }) => { +const Chat = () => { const router = useRouter(); + const { shareId = '', historyId = '' } = router.query as { shareId: string; historyId: string }; const theme = useTheme(); const ChatBox = useRef(null); @@ -837,11 +838,4 @@ const Chat = ({ shareId, historyId }: { shareId: string; historyId: string }) => ); }; -Chat.getInitialProps = ({ query, req }: any) => { - return { - shareId: query?.shareId || '', - historyId: query?.historyId || '' - }; -}; - export default Chat; diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index b788a55ac..0dee4c4e8 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -140,8 +140,10 @@ const Home = () => { useEffect(() => { (async () => { - const { data: git } = await axios.get('https://api.github.com/repos/c121914yu/FastGPT'); - setStar(git.stargazers_count); + try { + const { data: git } = await axios.get('https://api.github.com/repos/c121914yu/FastGPT'); + setStar(git.stargazers_count); + } catch (error) {} })(); }, []); diff --git a/client/src/pages/kb/index.tsx b/client/src/pages/kb/index.tsx index 49e4aad2c..d42f16763 100644 --- a/client/src/pages/kb/index.tsx +++ b/client/src/pages/kb/index.tsx @@ -7,8 +7,9 @@ import SideBar from '@/components/SideBar'; import KbList from './components/KbList'; import KbDetail from './components/Detail'; -const Kb = ({ kbId }: { kbId: string }) => { +const Kb = () => { const router = useRouter(); + const { kbId = '' } = router.query as { kbId: string }; const { isPc } = useGlobalStore(); const { lastKbId } = useUserStore(); @@ -35,9 +36,3 @@ const Kb = ({ kbId }: { kbId: string }) => { }; export default Kb; - -Kb.getInitialProps = ({ query, req }: any) => { - return { - kbId: query?.kbId || '' - }; -}; diff --git a/client/src/pages/model/index.tsx b/client/src/pages/model/index.tsx index b62882393..9da539802 100644 --- a/client/src/pages/model/index.tsx +++ b/client/src/pages/model/index.tsx @@ -13,8 +13,9 @@ const ModelDetail = dynamic(() => import('./components/detail/index'), { ssr: false }); -const Model = ({ modelId }: { modelId: string }) => { +const Model = () => { const router = useRouter(); + const { modelId = '' } = router.query as { modelId: string }; const { isPc } = useGlobalStore(); const { lastModelId } = useUserStore(); @@ -41,9 +42,3 @@ const Model = ({ modelId }: { modelId: string }) => { }; export default Model; - -Model.getInitialProps = ({ query, req }: any) => { - return { - modelId: query?.modelId || '' - }; -};