chatbox ui

This commit is contained in:
archer
2023-07-11 23:22:01 +08:00
parent eb768d9c04
commit b2e2f60e0d
46 changed files with 1123 additions and 2817 deletions

View File

@@ -5,12 +5,10 @@ import { authUser } from '@/service/utils/auth';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { chatId, contentId } = req.query as {
chatId: string;
contentId: string;
};
const { historyId, contentId } = req.query as { historyId: string; contentId: string };
console.log(historyId, contentId);
if (!chatId || !contentId) {
if (!historyId || !contentId) {
throw new Error('缺少参数');
}
@@ -19,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// 凭证校验
const { userId } = await authUser({ req, authToken: true });
const chatRecord = await Chat.findById(chatId);
const chatRecord = await Chat.findById(historyId);
if (!chatRecord) {
throw new Error('找不到对话');
@@ -28,7 +26,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// 删除一条数据库记录
await Chat.updateOne(
{
_id: chatId,
_id: historyId,
userId
},
{ $pull: { content: { _id: contentId } } }