From bd06998ac5215c6603585ee9c0d19ee1f67e4917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B0=91=E5=BA=B7?= Date: Fri, 30 May 2025 11:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BF=A1=E4=BB=A3=E7=A0=81=E5=BA=93-A?= =?UTF-8?q?I=E5=A4=A7=E6=A8=A1=E5=9E=8B=E6=94=B6=E8=97=8F=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewHistoryAside/ViewHistoryAside.vue | 286 ++++++++++-------- 1 file changed, 163 insertions(+), 123 deletions(-) diff --git a/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue b/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue index 7c7b384..4d8c0b5 100644 --- a/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue +++ b/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue @@ -55,9 +55,23 @@ - + - + + @@ -76,35 +90,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -138,85 +123,88 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
+ +
+
+ +
+ + + +
+ +
+
+ + {{ item.text || '可信代码库AI' }} +
+
+ {{ item.createTime||'--' }} +
+
+
+
+ +
+
+
@@ -234,15 +222,15 @@ 0
- - - - - - - - - + + + + + + + + + @@ -302,7 +290,6 @@ const startEdit = (item) => { // 确认编辑 const confirmEdit = async (item) => { - debugger if (!item.tempTitle.trim()) { Message.error('标题不能为空'); return; @@ -328,9 +315,38 @@ const confirmEdit = async (item) => { } }; +// 收藏状态切换 +const toggleCollect = async (item) => { + if (!props.username) { + return Message.error('请先登录'); + } + + try { + const res = await axios.post(`${VITE_AI_API_HOST}/api/toggleConversationCollect`, { + userId: props.username, + conversationId: item.conversationId + }); + + if (res.data.code === 20000) { + // 更新历史对话状态 + item.is_collected = res.data.isCollected; + + // 刷新收藏列表 + await getQuestionCollection(); + + Message.success(res.data.message); + } else { + Message.error(res.data.message || '操作失败'); + } + } catch (error) { + console.error('收藏操作失败:', error); + Message.error('网络请求失败,请重试'); + } +}; + + // 取消编辑 const cancelEdit = (item) => { - debugger item.isEditing = false; item.tempTitle = item.title; // 恢复原始标题 }; @@ -360,13 +376,13 @@ const cardList = ref([ } ]); const dhlsList = ref([]); +const collectionList = ref([]); const VITE_AI_API_HOST = import.meta.env.VITE_AI_API_HOST; const getQuestionHistory = async () => { if(props.username) { - const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username); + const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=history'); if(data.conversationList) { - debugger dhlsList.value = data.conversationList } else { // Message.error(data.error||'接口异常!') @@ -375,9 +391,22 @@ const getQuestionHistory = async () => { Message.error('请先登录!') } }; +const getQuestionCollection = async () => { + if(props.username) { + const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=collection'); + if(data.conversationList) { + collectionList.value = data.conversationList + } else { + // Message.error(data.error||'接口异常!') + } + } else { + Message.error('请先登录!') + } +}; onMounted(() => { getQuestionHistory() + getQuestionCollection() }); defineExpose({ @@ -467,4 +496,15 @@ defineExpose({ } } + +.list-menu { + padding: 8px; + .menu-item { + cursor: pointer; + display: flex; + align-items: baseline; + //justify-content: space-around; + } +} +