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 = ""; + } }, // 处理单个删除操作