From 195ee5b2a653cf9178ee246753bb42efe47750b5 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 21 Feb 2025 12:54:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(AccountSetting):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=A7=84=E5=88=99=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/setting/AccountSettingRule.vue | 62 +++++++++++++++--------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/views/setting/AccountSettingRule.vue b/src/views/setting/AccountSettingRule.vue index 77953a79..fed0bba6 100644 --- a/src/views/setting/AccountSettingRule.vue +++ b/src/views/setting/AccountSettingRule.vue @@ -16,7 +16,7 @@ const customRules = ref([]) const filterRuleGroups = ref([]) // 种子优先规则 -const selectedTorrentPriority = ref('seeder') +const selectedTorrentPriority = ref(['seeder']) // 二级分类策略 const mediaCategories = ref<{ [key: string]: any }>({}) @@ -240,32 +240,11 @@ function extractFilterRuleGroups(value: any) { // 根据ID简单区分规则与规则组 function checkValueValidity(values: any, type: string): boolean { try { - // 允许空值存在,不影响最终的导入 if (!values) return true if (!type) return false - for (const value of values) { - const keys = Object.keys(value) - const uniqueKeys = new Set(keys) - const hasName = keys.includes('name') - const hasId = keys.includes('id') - const noDuplicates = keys.length === uniqueKeys.size - if (type == 'custom') { - if (!hasName || !hasId || !noDuplicates) { - if (!noDuplicates) $toast.warning(`存在重名值`) - if (!hasId) $toast.error(`导入失败!发现有规则不存在ID,可能属于优先级规则组!`) - return false - } - } else if (type == 'group') { - if (!hasName || hasId || !noDuplicates) { - if (!noDuplicates) $toast.warning(`存在重名值`) - if (hasId) $toast.error(`导入失败!发现有规则存在ID,可能属于自定义规则!`) - return false - } - } else { - console.error(`传入了不合法的类型!`) - return false - } + for (const value of values) { + if (!isValidValue(value, type)) return false } return true } catch (e) { @@ -274,6 +253,41 @@ function checkValueValidity(values: any, type: string): boolean { } } +function isValidValue(value: any, type: string): boolean { + const keys = Object.keys(value) + const uniqueKeys = new Set(keys) + const hasName = keys.includes('name') + const hasId = keys.includes('id') + const noDuplicates = keys.length === uniqueKeys.size + + if (type === 'custom') { + return validateCustomRule(hasName, hasId, noDuplicates) + } else if (type === 'group') { + return validateGroupRule(hasName, hasId, noDuplicates) + } else { + console.error(`传入了不合法的类型!`) + return false + } +} + +function validateCustomRule(hasName: boolean, hasId: boolean, noDuplicates: boolean): boolean { + if (!hasName || !hasId || !noDuplicates) { + if (!noDuplicates) $toast.warning(`存在重名值`) + if (!hasId) $toast.error(`导入失败!发现有规则不存在ID,可能属于优先级规则组!`) + return false + } + return true +} + +function validateGroupRule(hasName: boolean, hasId: boolean, noDuplicates: boolean): boolean { + if (!hasName || hasId || !noDuplicates) { + if (!noDuplicates) $toast.warning(`存在重名值`) + if (hasId) $toast.error(`导入失败!发现有规则存在相同ID,可能属于自定义规则!`) + return false + } + return true +} + // 清空规则(组) function deleteAllRules(dateType: string) { if (!dateType) return From da09860a53e83db8ea44d12b344320edc586a90c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 21 Feb 2025 13:02:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(AccountSettingRule):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E4=B8=BAmdi-delete-empty-outline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/setting/AccountSettingRule.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/setting/AccountSettingRule.vue b/src/views/setting/AccountSettingRule.vue index fed0bba6..82604154 100644 --- a/src/views/setting/AccountSettingRule.vue +++ b/src/views/setting/AccountSettingRule.vue @@ -403,7 +403,7 @@ onMounted(() => { - + @@ -454,7 +454,7 @@ onMounted(() => { - + From 87239994ae169113de3211f3a000aac0c5f02163 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 21 Feb 2025 13:10:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(SiteCard):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cards/SiteCard.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/cards/SiteCard.vue b/src/components/cards/SiteCard.vue index 27a41c93..253a4d3f 100644 --- a/src/components/cards/SiteCard.vue +++ b/src/components/cards/SiteCard.vue @@ -191,6 +191,9 @@ onMounted(() => { +
+ ↑ {{ formatFileSize(cardProps.data?.upload || 0) }} / ↓ {{ formatFileSize(cardProps.data?.download || 0) }} +
@@ -228,9 +231,6 @@ onMounted(() => { - - ↑ {{ formatFileSize(cardProps.data?.upload || 0) }} / ↓ {{ formatFileSize(cardProps.data?.download || 0) }} -