From 6d2ad097a3cbf113c7b3fa8396def2b6788c0d52 Mon Sep 17 00:00:00 2001 From: digua Date: Thu, 16 Jul 2026 23:21:24 +0800 Subject: [PATCH] fix(analysis): preserve catchphrase member filter --- .../analysis/quotes/CatchphraseTab.vue | 5 ++--- .../quotes/catchphrase-record-query.test.ts | 20 +++++++++++++++++++ .../quotes/catchphrase-record-query.ts | 9 +++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/components/analysis/quotes/catchphrase-record-query.test.ts create mode 100644 src/components/analysis/quotes/catchphrase-record-query.ts diff --git a/src/components/analysis/quotes/CatchphraseTab.vue b/src/components/analysis/quotes/CatchphraseTab.vue index 207601fb..5f4af6e9 100644 --- a/src/components/analysis/quotes/CatchphraseTab.vue +++ b/src/components/analysis/quotes/CatchphraseTab.vue @@ -8,6 +8,7 @@ import { EmptyState, LoadingState, SectionCard } from '@/components/UI' import { useLayoutStore } from '@/stores/layout' import { formatRankNumber, getRankNumberClass } from '@/utils' import type { TimeFilter } from '@openchatlab/shared-types' +import { buildCatchphraseRecordQuery } from './catchphrase-record-query' const { t } = useI18n() const layoutStore = useLayoutStore() @@ -45,9 +46,7 @@ async function loadCatchphraseAnalysis() { } function handlePhraseClick(content: string) { - layoutStore.openChatRecordDrawer({ - keywords: [content], - }) + layoutStore.openChatRecordDrawer(buildCatchphraseRecordQuery(content, props.timeFilter)) } function getOverviewPhrases(member: MemberCatchphrase) { diff --git a/src/components/analysis/quotes/catchphrase-record-query.test.ts b/src/components/analysis/quotes/catchphrase-record-query.test.ts new file mode 100644 index 00000000..aefded1c --- /dev/null +++ b/src/components/analysis/quotes/catchphrase-record-query.test.ts @@ -0,0 +1,20 @@ +/** + * Run: pnpm test -- src/components/analysis/quotes/catchphrase-record-query.test.ts + */ + +import assert from 'node:assert/strict' +import test from 'node:test' +import { buildCatchphraseRecordQuery } from './catchphrase-record-query' + +test('keeps the selected member when opening catchphrase records', () => { + assert.deepEqual(buildCatchphraseRecordQuery('口头禅', { memberId: 42 }), { + keywords: ['口头禅'], + memberId: 42, + }) +}) + +test('keeps overview catchphrase records scoped only by keyword', () => { + assert.deepEqual(buildCatchphraseRecordQuery('口头禅'), { + keywords: ['口头禅'], + }) +}) diff --git a/src/components/analysis/quotes/catchphrase-record-query.ts b/src/components/analysis/quotes/catchphrase-record-query.ts new file mode 100644 index 00000000..c05e9210 --- /dev/null +++ b/src/components/analysis/quotes/catchphrase-record-query.ts @@ -0,0 +1,9 @@ +import type { TimeFilter } from '@openchatlab/shared-types' +import type { ChatRecordQuery } from '@/types/format' + +export function buildCatchphraseRecordQuery(content: string, timeFilter?: TimeFilter): ChatRecordQuery { + return { + keywords: [content], + ...(timeFilter?.memberId != null ? { memberId: timeFilter.memberId } : {}), + } +}