diff --git a/api/deepMate/deepMate.js b/api/deepMate/deepMate.js index 9416772..7b67999 100644 --- a/api/deepMate/deepMate.js +++ b/api/deepMate/deepMate.js @@ -54,6 +54,19 @@ export const postHistory = (data) => { /** + * 删除历史记录 + */ + +export const postDeleteHistory = (data) => { + return http({ + method: 'POST', + url: '/api/deepMate/deleteRecord', + data + }) +} + + +/** * 历史记录详情 */ diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue index 657f181..74b2536 100644 --- a/pages/deepMate/deepMate.vue +++ b/pages/deepMate/deepMate.vue @@ -250,7 +250,8 @@ 删除全部 @@ -312,6 +313,7 @@ import { postIntent, postHistory, postHistoryDetail, + postDeleteHistory, } from "../../api/deepMate/deepMate"; import { useUserStore } from "../../stores/modules/userInfo"; @@ -597,22 +599,36 @@ const groupedHistory = computed(() => { const clearAllHistory = () => { uni.showModal({ - title: '确认删除', - content: '确定要删除全部历史记录吗?该操作不可撤销。', - confirmText: '删除', - cancelText: '取消', + title: "确认删除", + content: "确定要删除全部历史记录吗?该操作不可撤销。", + confirmText: "删除", + cancelText: "取消", success: (res) => { if (res.confirm) { - // 当前历史面板依赖 historyList,而非 searchHistory - historyList.value = []; - // 同步清空本地旧缓存(如果曾使用) - // uni.setStorageSync("search_history", []); - uni.showToast({ title: '历史已清空', icon: 'none' }); + deleteHistory(); } - } - }) + }, + }); }; +// 删除历史记录 +async function deleteHistory(historyId) { + // 当前历史面板依赖 historyList,而非 searchHistory + // 同步清空本地旧缓存(如果曾使用) + const res = await postDeleteHistory({ + model: 5, + }); + if (res.code === 200) { + historyList.value = []; + + // uni.setStorageSync("search_history", []); + uni.showToast({ title: "历史已清空", icon: "none" }); + } + else { + uni.showToast({ title: res.message, icon: "none" }); + } +} + // 发送消息 const sendMessage = () => { if (inputMessage.value.trim() === "" || isSending.value) return; @@ -694,18 +710,18 @@ const simulateBotResponse = async (userMessage) => { let ch = responseText.charAt(index); let charsToAdd = ch; let newIndex = index + 1; - + // 检查是否遇到HTML标签开始 - if (ch === '<') { + if (ch === "<") { // 寻找标签结束位置 - let tagEndIndex = responseText.indexOf('>', index); + let tagEndIndex = responseText.indexOf(">", index); if (tagEndIndex !== -1) { // 完整获取标签内容 charsToAdd = responseText.substring(index, tagEndIndex + 1); newIndex = tagEndIndex + 1; } } - + const current = messages.value[botIndex]; // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应 messages.value.splice(botIndex, 1, { @@ -720,10 +736,10 @@ const simulateBotResponse = async (userMessage) => { const baseDelay = 5; // 普通字符基础延迟(毫秒) const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿 const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿 - + // 如果是标签,使用更短的延迟或者立即显示 let delay; - if (charsToAdd.startsWith('<')) { + if (charsToAdd.startsWith("<")) { delay = 1; // 标签快速显示 } else { delay = slowPunct.test(ch) @@ -826,11 +842,11 @@ const simulateBotResponse = async (userMessage) => { let charsToAdd = ch; let newIndex = index + 1; let delay = baseDelay; - + // 检查是否遇到HTML标签开始 - if (ch === '<') { + if (ch === "<") { // 寻找标签结束位置 - let tagEndIndex = responseText.indexOf('>', index); + let tagEndIndex = responseText.indexOf(">", index); if (tagEndIndex !== -1) { // 完整获取标签内容 charsToAdd = responseText.substring(index, tagEndIndex + 1); @@ -838,7 +854,7 @@ const simulateBotResponse = async (userMessage) => { delay = 1; // 标签快速显示 } } - + const current = messages.value[botIndex]; // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应 messages.value.splice(botIndex, 1, { @@ -1841,7 +1857,6 @@ async function itemClick(item) { to { transform: scaleY(1); } - } .thinking-item {