From 6583861586f862358a651e5a0a421a83d926dc0b Mon Sep 17 00:00:00 2001 From: wizardchen Date: Tue, 30 Dec 2025 11:29:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/menu.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/menu.vue b/frontend/src/components/menu.vue index da2c6057..d7566329 100644 --- a/frontend/src/components/menu.vue +++ b/frontend/src/components/menu.vue @@ -432,18 +432,27 @@ const handleSessionMenuClick = (data: { value: string }, index: number, item: an const delCard = (index: number, item: any) => { delSession(item.id).then((res: any) => { if (res && (res as any).success) { - // 使用 originalIndex 找到正确的位置进行删除 - const actualIndex = index !== undefined ? index : - (menuArr.value as any[])[1]?.children?.findIndex((s: any) => s.id === item.id); + // 找到 'creatChat' 菜单项 + const chatMenuItem = (menuArr.value as any[]).find((m: any) => m.path === 'creatChat'); - if (actualIndex !== -1) { - (menuArr.value as any[])[1]?.children?.splice(actualIndex, 1); + if (chatMenuItem && chatMenuItem.children) { + const children = chatMenuItem.children; + // 通过ID查找索引,比依赖传入的index更安全 + const actualIndex = children.findIndex((s: any) => s.id === item.id); + + if (actualIndex !== -1) { + children.splice(actualIndex, 1); + } } if (item.id == route.params.chatid) { // 删除当前会话后,跳转到全局创建聊天页面 router.push('/platform/creatChat'); } + // 更新总数 + if (total.value > 0) { + total.value--; + } } else { MessagePlugin.error("删除失败,请稍后再试!"); }