style: Update FilterRuleCard and FilterRuleGroupCard to include custom_rules prop

This commit is contained in:
jxxghp
2024-08-12 08:02:35 +08:00
parent 3b1a9bd0c4
commit 676ff8789b
3 changed files with 33 additions and 14 deletions

View File

@@ -1,10 +1,11 @@
<script lang="ts" setup>
import { CustomRule } from '@/api/types'
// 输入参数
const props = defineProps({
pri: String,
rules: Array as PropType<string[]>,
width: String,
height: String,
custom_rules: Array as PropType<CustomRule[]>,
})
// 定义触发的自定义事件
@@ -61,6 +62,17 @@ const selectFilterOptions = ref<{ [key: string]: string }[]>([
{ title: '效果: 3D', value: ' 3D ' },
{ title: '排除: 3D', value: ' !3D ' },
])
onMounted(() => {
if (props.custom_rules) {
props.custom_rules.map(rule => {
selectFilterOptions.value.push({
title: rule.name,
value: rule.id,
})
})
}
})
</script>
<template>

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import { copyToClipboard } from '@/@core/utils/navigator'
import { FilterRuleGroup } from '@/api/types'
import { CustomRule, FilterRuleGroup } from '@/api/types'
import FilterRuleCard from '@/components/cards/FilterRuleCard.vue'
import { useToast } from 'vue-toast-notification'
import ImportCodeDialog from '@/components/dialog/ImportCodeDialog.vue'
@@ -13,6 +13,7 @@ const props = defineProps({
type: Object as PropType<FilterRuleGroup>,
required: true,
},
custom_rules: Array as PropType<CustomRule[]>,
})
// 规则卡片类型
@@ -212,6 +213,7 @@ function onClose() {
:pri="element.pri"
:maxpri="filterRuleCards.length.toString()"
:rules="element.rules"
:custom_rules="props.custom_rules"
@changed="updateFilterCardValue"
@close="filterCardClose(element.pri)"
/>

View File

@@ -27,16 +27,6 @@ const TorrentPriorityItems = [
{ title: '资源做种数优先', value: 'seeder' },
]
// 加载自定义规则
async function queryCustomRules() {
try {
const result: { [key: string]: any } = await api.get('system/setting/CustomFilterRules')
customRules.value = result.data?.value ?? []
} catch (error) {
console.log(error)
}
}
// 保存自定义规则
async function saveCustomRules() {
try {
@@ -123,6 +113,16 @@ async function queryTorrentPriority() {
}
}
// 查询自定义规则项
async function queryCustomRules() {
try {
const result: { [key: string]: any } = await api.get('system/setting/CustomFilterRules')
customRules.value = result.data?.value ?? []
} catch (error) {
console.log(error)
}
}
// 保存种子优先规则
async function saveTorrentPriority() {
try {
@@ -191,7 +191,12 @@ onMounted(() => {
:component-data="{ 'class': 'grid gap-3 grid-app-card' }"
>
<template #item="{ element }">
<FilterRuleGroupCard :group="element" @close="removeFilterRuleGroup(element)" @change="changeRuleGroup" />
<FilterRuleGroupCard
:group="element"
:custom_rules="customRules"
@close="removeFilterRuleGroup(element)"
@change="changeRuleGroup"
/>
</template>
</draggable>
</VCardText>