diff --git a/src/api/types.ts b/src/api/types.ts
index d78d6954..d1bcb11d 100644
--- a/src/api/types.ts
+++ b/src/api/types.ts
@@ -954,13 +954,15 @@ export interface CustomRule {
// 名称
name: string
// 包含
- include?: string[]
+ include?: string
// 排除
- exclude?: string[]
+ exclude?: string
// 大小范围
size_range?: string
// 最少做种人数
seeders?: string
+ // 发布时间
+ publish_time?: string
}
// 过滤规则组
diff --git a/src/components/cards/CustomRuleCard.vue b/src/components/cards/CustomRuleCard.vue
index 11645e02..ca80bcce 100644
--- a/src/components/cards/CustomRuleCard.vue
+++ b/src/components/cards/CustomRuleCard.vue
@@ -1,2 +1,82 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/cards/FilterRuleCard.vue b/src/components/cards/FilterRuleCard.vue
index a9131b86..60d7a897 100644
--- a/src/components/cards/FilterRuleCard.vue
+++ b/src/components/cards/FilterRuleCard.vue
@@ -2,7 +2,6 @@
// 输入参数
const props = defineProps({
pri: String,
- maxpri: String,
rules: Array as PropType,
width: String,
height: String,
diff --git a/src/views/setting/AccountSettingRule.vue b/src/views/setting/AccountSettingRule.vue
index a980ba67..9fddb054 100644
--- a/src/views/setting/AccountSettingRule.vue
+++ b/src/views/setting/AccountSettingRule.vue
@@ -26,17 +26,78 @@ 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)
+ }
+}
+
// 保存自定义规则
-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() {
@@ -67,6 +128,8 @@ async function saveTorrentPriority() {
// 加载数据
onMounted(() => {
+ queryCustomRules()
+ queryFilterRuleGroups()
queryTorrentPriority()
})
@@ -88,7 +151,7 @@ onMounted(() => {
:component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }"
>
-
+
@@ -115,7 +178,7 @@ onMounted(() => {
:component-data="{ 'class': 'grid gap-3 grid-filterrule-card' }"
>
-
+