mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
feat(filter): 支持音乐优先级规则组
This commit is contained in:
+1
-1
@@ -1810,7 +1810,7 @@ export interface FilterRuleGroup {
|
|||||||
name: string
|
name: string
|
||||||
// 规则串
|
// 规则串
|
||||||
rule_string?: string
|
rule_string?: string
|
||||||
// 适用类媒体类型 None-全部 电影/电视剧
|
// 适用媒体类型 None-全部 电影/电视剧/音乐
|
||||||
media_type?: string
|
media_type?: string
|
||||||
// # 适用媒体类别 None-全部 对应二级分类
|
// # 适用媒体类别 None-全部 对应二级分类
|
||||||
category?: string
|
category?: string
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ const mediaTypeItems = [
|
|||||||
{ title: t('common.all'), value: '' },
|
{ title: t('common.all'), value: '' },
|
||||||
{ title: t('mediaType.movie'), value: '电影' },
|
{ title: t('mediaType.movie'), value: '电影' },
|
||||||
{ title: t('mediaType.tv'), 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] || [])
|
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<FilterCard[]>([])
|
const filterRuleCards = ref<FilterCard[]>([])
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user