feat: chat ui

This commit is contained in:
archer
2023-07-26 11:01:25 +08:00
parent 2b993b926a
commit 248be38939
19 changed files with 153 additions and 54 deletions

View File

@@ -3,18 +3,31 @@ import { jsonRes } from '@/service/response';
import { connectToDatabase, Chat } from '@/service/mongo';
import { authUser } from '@/service/utils/auth';
/* 获取历史记录 */
type Props = {
chatId?: string;
appId?: string;
};
/* clear chat history */
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { chatId } = req.query;
const { chatId, appId } = req.query as Props;
const { userId } = await authUser({ req, authToken: true });
await connectToDatabase();
await Chat.findOneAndRemove({
chatId,
userId
});
if (chatId) {
await Chat.findOneAndRemove({
chatId,
userId
});
}
if (appId) {
await Chat.deleteMany({
appId,
userId
});
}
jsonRes(res);
} catch (err) {