From d28fab0fe57ca0df049d19a308318306ba0e3e73 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 25 Aug 2026 16:33:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(filter):=20=E6=94=AF=E6=8C=81=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E4=BC=98=E5=85=88=E7=BA=A7=E8=A7=84=E5=88=99=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/types.ts | 2 +- .../dialog/FilterRuleGroupInfoDialog.vue | 8 +++++ .../FilterRuleGroupInfoDialog.spec.ts | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/components/dialog/__tests__/FilterRuleGroupInfoDialog.spec.ts diff --git a/src/api/types.ts b/src/api/types.ts index 5ea9d7dd..80d4e0eb 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1810,7 +1810,7 @@ export interface FilterRuleGroup { name: string // 规则串 rule_string?: string - // 适用类媒体类型 None-全部 电影/电视剧 + // 适用媒体类型 None-全部 电影/电视剧/音乐 media_type?: string // # 适用媒体类别 None-全部 对应二级分类 category?: string diff --git a/src/components/dialog/FilterRuleGroupInfoDialog.vue b/src/components/dialog/FilterRuleGroupInfoDialog.vue index a2d1c968..7465179c 100644 --- a/src/components/dialog/FilterRuleGroupInfoDialog.vue +++ b/src/components/dialog/FilterRuleGroupInfoDialog.vue @@ -79,6 +79,7 @@ const mediaTypeItems = [ { title: t('common.all'), value: '' }, { title: t('mediaType.movie'), value: '电影' }, { title: t('mediaType.tv'), value: '电视剧' }, + { title: t('mediaType.music'), value: '音乐' }, ] // 根据选中的媒体类型,获取对应的媒体类别 @@ -90,6 +91,13 @@ const getCategories = computed(() => { return default_value.concat(props.categories[groupInfo.value.media_type] || []) }) +watch( + () => groupInfo.value.media_type, + (mediaType, previousMediaType) => { + if (mediaType !== previousMediaType) groupInfo.value.category = '' + }, +) + // 规则组规则卡片列表 const filterRuleCards = ref([]) diff --git a/src/components/dialog/__tests__/FilterRuleGroupInfoDialog.spec.ts b/src/components/dialog/__tests__/FilterRuleGroupInfoDialog.spec.ts new file mode 100644 index 00000000..a061040b --- /dev/null +++ b/src/components/dialog/__tests__/FilterRuleGroupInfoDialog.spec.ts @@ -0,0 +1,35 @@ +import FilterRuleGroupInfoDialog from '@/components/dialog/FilterRuleGroupInfoDialog.vue' +import userEvent from '@testing-library/user-event' +import { screen } from '@testing-library/vue' +import { renderWithProviders } from '@tests/support/render' +import { describe, expect, it, vi } from 'vitest' + +vi.mock('vue-toastification', () => ({ + useToast: () => ({ error: vi.fn(), success: vi.fn() }), +})) + +vi.mock('@/composables/useSharedDialog', () => ({ + openSharedDialog: vi.fn(), +})) + +describe('FilterRuleGroupInfoDialog', () => { + it('offers music as a rule group media type', async () => { + const user = userEvent.setup() + await renderWithProviders(FilterRuleGroupInfoDialog, { + props: { + modelValue: true, + group: { name: '音乐规则', rule_string: 'FLAC', media_type: '', category: '' }, + groups: [], + categories: {}, + custom_rules: [], + }, + global: { + stubs: { VDialogCloseBtn: true }, + }, + }) + + await user.click(screen.getByRole('textbox', { name: '媒体类型' })) + + expect(await screen.findByRole('option', { name: '音乐' })).toBeVisible() + }) +})