From b1cf4b9ff25ccbba7c8b9a33a08d56d507853694 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Fri, 29 May 2026 19:57:23 +0800 Subject: [PATCH] fix(frontend): restore conversation delete animation Use a two-phase delete flow for conversation list items. Instead of immediately removing the deleted conversation from the array and relying only on transition-group leave hooks, mark the target conversation as pending deletion first so it can play the left-slide animation, then remove it after the animation completes. Also keep the list container mounted during delete mode so empty/loading branches do not interrupt the exit transition. Validation: npm run build --silent 2>&1 | tail -n 20 --- static/src/app/computed.ts | 1 + static/src/app/methods/conversation.ts | 23 +++++++++++++++++-- .../sidebar/ConversationSidebar.vue | 9 +++++--- static/src/stores/conversation.ts | 3 +++ .../components/sidebar/_conversation.scss | 9 ++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/static/src/app/computed.ts b/static/src/app/computed.ts index 9154dae..1a83d3c 100644 --- a/static/src/app/computed.ts +++ b/static/src/app/computed.ts @@ -58,6 +58,7 @@ export const computed = { 'searchResults', 'conversationInsertAnimations', 'conversationListAnimationMode', + 'pendingDeletingConversationIds', 'searchActive', 'searchInProgress', 'searchMoreAvailable', diff --git a/static/src/app/methods/conversation.ts b/static/src/app/methods/conversation.ts index 18e84da..b35414e 100644 --- a/static/src/app/methods/conversation.ts +++ b/static/src/app/methods/conversation.ts @@ -631,17 +631,31 @@ export const conversationMethods = { history.replaceState({}, '', '/new'); } - // 先从本地列表移除,让侧边栏执行删除动画;随后再刷新服务端列表补齐分页状态 + // 先给目标项加 deleting 类执行左滑动画,再从本地列表移除。 + // 这比完全依赖 transition-group leave 更稳定:即使列表即将为空或分支切换,也能先播放离场动画。 this.conversationListAnimationMode = 'delete'; + const deletingIds = Array.isArray(this.pendingDeletingConversationIds) + ? this.pendingDeletingConversationIds + : []; + if (!deletingIds.includes(conversationId)) { + this.pendingDeletingConversationIds = [...deletingIds, conversationId]; + } + await this.$nextTick(); + await waitForAnimation(430); + this.conversations = this.conversations.filter( (conversation) => conversation.id !== conversationId ); this.searchResults = this.searchResults.filter( (conversation) => conversation.id !== conversationId ); + this.pendingDeletingConversationIds = (Array.isArray(this.pendingDeletingConversationIds) + ? this.pendingDeletingConversationIds + : [] + ).filter((id) => id !== conversationId); // 等待“左滑离场 + 0.1s 后集体上移”动画结束,避免刷新列表打断过渡。 - await waitForAnimation(560); + await waitForAnimation(180); // 刷新对话列表 this.conversationsOffset = 0; @@ -656,6 +670,11 @@ export const conversationMethods = { }); } } catch (error) { + this.pendingDeletingConversationIds = (Array.isArray(this.pendingDeletingConversationIds) + ? this.pendingDeletingConversationIds + : [] + ).filter((id) => id !== conversationId); + this.conversationListAnimationMode = 'idle'; console.error('删除对话异常:', error); this.uiPushToast({ title: '删除对话异常', diff --git a/static/src/components/sidebar/ConversationSidebar.vue b/static/src/components/sidebar/ConversationSidebar.vue index 77500cd..5195920 100644 --- a/static/src/components/sidebar/ConversationSidebar.vue +++ b/static/src/components/sidebar/ConversationSidebar.vue @@ -129,12 +129,12 @@
正在加载...
-
+
{{ searchActive ? '未找到匹配对话' : '暂无对话记录' }}