删除聊天记录功能开发

This commit is contained in:
冯辉
2026-03-16 14:28:38 +08:00
parent 23a286cb64
commit 5046e7467f
2 changed files with 209 additions and 4 deletions

View File

@@ -335,6 +335,22 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
}))
}
// 删除消息
async function deleteMessages(indices) {
// 按索引从大到小排序,避免删除时索引变化
const sortedIndices = [...indices].sort((a, b) => b - a);
// 从内存中删除消息
for (const index of sortedIndices) {
const message = messages.value[index];
if (message && message.id) {
// 从本地数据库中删除
await baseDB.db.delete(massageName.value, message.id);
}
messages.value.splice(index, 1);
}
}
return {
messages,
isTyping,
@@ -348,7 +364,8 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
changeDialogue,
getStearm,
getHistory,
badFeedback
badFeedback,
deleteMessages
};
});