From 909cf265494eaa52ca93f5e88fc362e9a14a3205 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Thu, 18 Dec 2025 09:17:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95):?= =?UTF-8?q?=20=E5=AE=9E=E7=8E=B0=E4=BE=A7=E6=BB=91=E4=BA=92=E6=96=A5?= =?UTF-8?q?=EF=BC=9A=E6=89=93=E5=BC=80=E6=96=B0=E9=A1=B9=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=94=B6=E8=B5=B7=E6=97=A7=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/history/index.vue | 41 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/pages/home/history/index.vue b/pages/home/history/index.vue index bf888ea..457e1b1 100644 --- a/pages/home/history/index.vue +++ b/pages/home/history/index.vue @@ -52,7 +52,7 @@ {{ group.id }} - + - + @@ -164,6 +167,7 @@ export default { chatHistoryAI: [], // ai咨询历史记录 chatHistoryTeacher: [], // 人工咨询历史记录 openedItems: {}, // 记录每个项目的滑动状态 + openedSwipeId: "", // 当前展开的侧滑项 id }; }, computed: { @@ -207,16 +211,9 @@ export default { // 重置滑动状态 closeAllSwipeActions() { - const swipeActionRefs = this.$refs.swipeActionRef || []; - const refs = Array.isArray(swipeActionRefs) - ? swipeActionRefs - : [swipeActionRefs]; - - refs.forEach((ref) => { - if (ref && typeof ref.closeAll === "function") { - ref.closeAll(); - } - }); + const ids = this.currentHistoryItemIds || []; + ids.forEach((id) => this.closeSwipeActionById(id)); + this.openedSwipeId = ""; }, // 清空 openedItems 并调用 closeAllSwipeActions() @@ -225,6 +222,16 @@ export default { this.closeAllSwipeActions(); }, + closeSwipeActionById(itemId) { + if (!itemId) return; + const swipeRef = this.$refs[`swipe-${itemId}`]; + const ref = Array.isArray(swipeRef) ? swipeRef[0] : swipeRef; + if (ref && typeof ref.closeAll === "function") { + ref.closeAll(); + } + this.$set(this.openedItems, itemId, "none"); + }, + // 获取ai历史记录 async getChatHistoryList() { this.$u.api.GetConversationPage().then((res) => { @@ -465,6 +472,16 @@ export default { // 处理滑动操作变化 handleSwipeChange(e, itemId) { this.$set(this.openedItems, itemId, e); + if (e === "right" || e === "left") { + if (this.openedSwipeId && this.openedSwipeId !== itemId) { + this.closeSwipeActionById(this.openedSwipeId); + } + this.openedSwipeId = itemId; + return; + } + if (e === "none" && this.openedSwipeId === itemId) { + this.openedSwipeId = ""; + } }, // 处理单个删除操作