style: Update CustomRuleCard.vue to include publish_time field

This commit is contained in:
jxxghp
2024-08-05 18:15:04 +08:00
parent f043447e4f
commit 235eb82c45
4 changed files with 155 additions and 11 deletions
+4 -2
View File
@@ -954,13 +954,15 @@ export interface CustomRule {
// 名称 // 名称
name: string name: string
// 包含 // 包含
include?: string[] include?: string
// 排除 // 排除
exclude?: string[] exclude?: string
// 大小范围 // 大小范围
size_range?: string size_range?: string
// 最少做种人数 // 最少做种人数
seeders?: string seeders?: string
// 发布时间
publish_time?: string
} }
// 过滤规则组 // 过滤规则组
+82 -2
View File
@@ -1,2 +1,82 @@
<script setup lang="ts"></script> <script lang="ts" setup>
<template></template> import { CustomRule } from '@/api/types'
// 输入参数
const props = defineProps({
rule: {
type: Object as PropType<CustomRule>,
required: true,
},
})
// 定义触发的自定义事件
const emit = defineEmits(['close'])
// 按钮点击
function onClose() {
emit('close')
}
</script>
<template>
<VCard variant="tonal">
<DialogCloseBtn @click="onClose" />
<VCardItem>
<VTextField
v-model="props.rule.id"
variant="underlined"
label="规则编码"
class="me-20 text-high-emphasis font-weight-bold"
/>
<span class="absolute top-3 right-12">
<IconBtn>
<VIcon class="cursor-move" icon="mdi-drag" />
</IconBtn>
</span>
</VCardItem>
<VCardText>
<VForm>
<VRow>
<VCol cols="12">
<VTextField v-model="props.rule.name" variant="underlined" label="规则名称" />
</VCol>
<VCol cols="12">
<VTextField
v-model="props.rule.include"
variant="underlined"
placeholder="关键字/正则表达式"
label="包含"
/>
</VCol>
<VCol cols="12">
<VTextField
v-model="props.rule.exclude"
variant="underlined"
placeholder="关键字/正则表达式"
label="排除"
/>
</VCol>
<VCol cols="6">
<VTextField
v-model="props.rule.size_range"
variant="underlined"
placeholder="0/1-10"
label="大小范围(MB"
/>
</VCol>
<VCol cols="6">
<VTextField v-model="props.rule.size_range" variant="underlined" placeholder="0/1-10" label="做种人数" />
</VCol>
<VCol cols="6">
<VTextField
v-model="props.rule.publish_time"
variant="underlined"
placeholder="0"
label="发布时间(分钟)"
/>
</VCol>
</VRow>
</VForm>
</VCardText>
</VCard>
</template>
-1
View File
@@ -2,7 +2,6 @@
// 输入参数 // 输入参数
const props = defineProps({ const props = defineProps({
pri: String, pri: String,
maxpri: String,
rules: Array as PropType<string[]>, rules: Array as PropType<string[]>,
width: String, width: String,
height: String, height: String,
+69 -6
View File
@@ -26,17 +26,78 @@ const TorrentPriorityItems = [
{ title: '做种数优先', value: 'seeder' }, { 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)
}
}
// 保存自定义规则 // 保存自定义规则
function saveCustomRules() {} async function saveCustomRules() {
try {
const result: { [key: string]: any } = await api.post('system/setting/CustomFilterRules', customRules.value)
if (result.success) $toast.success('自定义规则保存成功')
else $toast.error('自定义规则保存失败!')
} catch (error) {
console.log(error)
}
}
// 添加自定义规则 // 添加自定义规则
function addCustomRule() {} function addCustomRule() {
customRules.value.push({
id: `RULE${customRules.value.length + 1}`,
name: `规则${customRules.value.length + 1}`,
include: '',
exclude: '',
})
}
// 移除自定义规则
function removeCustomRule(rule: CustomRule) {
const index = customRules.value.findIndex(item => item.id === rule.id)
if (index !== -1) customRules.value.splice(index, 1)
}
// 加载规则组
async function queryFilterRuleGroups() {
try {
const result: { [key: string]: any } = await api.get('system/setting/UserFilterRuleGroups')
filterRuleGroups.value = result.data?.value ?? []
} catch (error) {
console.log(error)
}
}
// 保存规则组 // 保存规则组
function saveFilterRuleGroups() {} async function saveFilterRuleGroups() {
try {
const result: { [key: string]: any } = await api.post('system/setting/UserFilterRuleGroups', filterRuleGroups.value)
if (result.success) $toast.success('优先级规则组保存成功')
else $toast.error('优先级规则组保存失败!')
} catch (error) {
console.log(error)
}
}
// 添加规则组 // 添加规则组
function addFilterRuleGroup() {} function addFilterRuleGroup() {
filterRuleGroups.value.push({
name: `规则组${filterRuleGroups.value.length + 1}`,
rule_string: '',
media_type: '',
})
}
// 移除规则组
function removeFilterRuleGroup(rule: FilterRuleGroup) {
const index = filterRuleGroups.value.findIndex(item => item.name === rule.name)
if (index !== -1) filterRuleGroups.value.splice(index, 1)
}
// 查询种子优先规则 // 查询种子优先规则
async function queryTorrentPriority() { async function queryTorrentPriority() {
@@ -67,6 +128,8 @@ async function saveTorrentPriority() {
// 加载数据 // 加载数据
onMounted(() => { onMounted(() => {
queryCustomRules()
queryFilterRuleGroups()
queryTorrentPriority() queryTorrentPriority()
}) })
</script> </script>
@@ -88,7 +151,7 @@ onMounted(() => {
:component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }" :component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }"
> >
<template #item="{ element }"> <template #item="{ element }">
<CustomerRuleCard :rule="element" /> <CustomerRuleCard :rule="element" @close="removeCustomRule(element)" />
</template> </template>
</draggable> </draggable>
</VCardText> </VCardText>
@@ -115,7 +178,7 @@ onMounted(() => {
:component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }" :component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }"
> >
<template #item="{ element }"> <template #item="{ element }">
<FilterRuleGroupCard type="library" :filterrule="element" /> <FilterRuleGroupCard :filterrule="element" @close="removeFilterRuleGroup(element)" />
</template> </template>
</draggable> </draggable>
</VCardText> </VCardText>