From 1c364eca35b786cdc1bfec432aad1a10c6cf14c7 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Sat, 18 Mar 2023 01:09:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A9=BA=E5=86=85=E5=AE=B9=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/api/timer/clearChatWindow.ts | 4 ++-- src/pages/chat/components/Empty.tsx | 24 ++++++++++++++++++++++++ src/pages/chat/index.tsx | 7 ++++--- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/pages/chat/components/Empty.tsx diff --git a/src/pages/api/timer/clearChatWindow.ts b/src/pages/api/timer/clearChatWindow.ts index 390db323b..ac3878419 100644 --- a/src/pages/api/timer/clearChatWindow.ts +++ b/src/pages/api/timer/clearChatWindow.ts @@ -1,13 +1,13 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { jsonRes } from '@/service/response'; -import { connectToDatabase, ChatWindow } from '@/service/mongo'; +import { connectToDatabase, Chat } from '@/service/mongo'; /* 定时删除那些不活跃的内容 */ export default async function handler(req: NextApiRequest, res: NextApiResponse) { try { await connectToDatabase(); - const response = await ChatWindow.deleteMany( + const response = await Chat.deleteMany( { $expr: { $lt: [{ $size: '$content' }, 5] } }, // 使用 $pull 操作符删除数组中的元素 { $pull: { content: { $exists: true } } } diff --git a/src/pages/chat/components/Empty.tsx b/src/pages/chat/components/Empty.tsx new file mode 100644 index 000000000..2733e9235 --- /dev/null +++ b/src/pages/chat/components/Empty.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Card, Flex, Box } from '@chakra-ui/react'; + +const Empty = () => { + return ( + + + + Fast Gpt version1.3 + + + 更新了聊天的数据结构,如果出现问题,请手动删除左侧旧的历史记录,并重新从模型页生成对话框进入。 + + 分享聊天使用的是分享者的 Api Key 进行收费,请确认分享安全 +
+ 分享空白聊天,会分享一个该模型的空白聊天页 +
+ 分享当前聊天,会把当前聊天的内容分享出去,请注意不会多人同时使用一个对话框 +
+
+ ); +}; + +export default Empty; diff --git a/src/pages/chat/index.tsx b/src/pages/chat/index.tsx index 95c84f81f..dbe86355b 100644 --- a/src/pages/chat/index.tsx +++ b/src/pages/chat/index.tsx @@ -17,7 +17,6 @@ import { Button, useDisclosure, Drawer, - DrawerFooter, DrawerOverlay, DrawerContent } from '@chakra-ui/react'; @@ -31,6 +30,7 @@ import { useGlobalStore } from '@/store/global'; import { useChatStore } from '@/store/chat'; import { streamFetch } from '@/api/fetch'; import SlideBar from './components/SlideBar'; +import Empty from './components/Empty'; import { getToken } from '@/utils/user'; const Markdown = dynamic(() => import('@/components/Markdown')); @@ -433,12 +433,13 @@ const Chat = ({ chatId }: { chatId: string }) => { ))} + {chatData.history.length === 0 && } {/* 发送区 */}