From 7e8624674e000ee62883fe2ece67e269d3fc811a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Tue, 25 Aug 2026 21:03:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(staffchat):=20SessionPane=20=E8=A1=A5?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=BA=8F=E5=8F=B7=E9=98=B2=E7=AB=9E=E6=80=81?= =?UTF-8?q?(=E5=AF=B9=E9=BD=90=E5=85=A8=20pane=20=E6=83=AF=E4=BE=8B)+?= =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E5=8D=A1=E4=B8=8D=E6=98=BE=E4=BB=8A=E6=97=A5?= =?UTF-8?q?=E7=BA=A2=E7=82=B9(spec=20=C2=A75)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- .../src/components/staffchat/SessionPane.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/yunkes/src/components/staffchat/SessionPane.vue b/yunkes/src/components/staffchat/SessionPane.vue index 513bf97..f73a9ac 100644 --- a/yunkes/src/components/staffchat/SessionPane.vue +++ b/yunkes/src/components/staffchat/SessionPane.vue @@ -40,7 +40,13 @@ function clearSearch() { searchTruncated.value = false } +/** 请求序号: ownerId/kind/tab/模式切换后在途旧响应整体丢弃(防竞态覆盖新员工/新 tab 的数据)。 + load 与 runSearch 共用同一序号——两者共享 loading/错误态,且 ownerId 切换只重发 load, + 共号才能把旧 owner 在途的搜索响应一并作废(对齐全 pane 惯例: MomentsPane 单 seq)。 */ +let seq = 0 + async function load() { + const mySeq = ++seq loading.value = true errorMsg.value = null clearSearch() @@ -50,12 +56,14 @@ async function load() { channel: props.channel, ...(props.kind === 'single' ? { is_del: friendTab.value === 'deleted' ? 1 : 0 } : {}), }) + if (mySeq !== seq) return sessions.value = res.sessions } catch (e) { + if (mySeq !== seq) return errorMsg.value = (e as Error).message sessions.value = [] } finally { - loading.value = false + if (mySeq === seq) loading.value = false } } watch(() => [props.ownerId, props.kind] as const, load, { immediate: true }) @@ -128,6 +136,7 @@ async function runSearch() { clearSearch() return } + const mySeq = ++seq loading.value = true errorMsg.value = null try { @@ -138,6 +147,7 @@ async function runSearch() { page: 1, page_size: 100, }) + if (mySeq !== seq) return searchTotal.value = res.total searchTruncated.value = res.total > res.items.length // 已加载的会话列表提供昵称/头像;未命中(search 只回消息)再以 sender_name/键兜底 @@ -165,10 +175,11 @@ async function runSearch() { (a, b) => (b.last_chat_time ?? 0) - (a.last_chat_time ?? 0), ) } catch (e) { + if (mySeq !== seq) return errorMsg.value = (e as Error).message clearSearch() } finally { - loading.value = false + if (mySeq === seq) loading.value = false } } @@ -228,7 +239,8 @@ async function runSearch() {
{{ displayName(s) }} - 今日{{ s.today_count }} + + 今日{{ s.today_count }}
{{ relativeChatTime(s.last_chat_time) }}