mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-02 22:31:07 +08:00
Merge branch 'v2' of https://github.com/jxxghp/MoviePilot-Frontend into v2
This commit is contained in:
@@ -191,6 +191,9 @@ onMounted(() => {
|
||||
</VTooltip>
|
||||
</VCardText>
|
||||
<VCardActions>
|
||||
<div class="text-sm">
|
||||
↑ {{ formatFileSize(cardProps.data?.upload || 0) }} / ↓ {{ formatFileSize(cardProps.data?.download || 0) }}
|
||||
</div>
|
||||
<IconBtn>
|
||||
<VIcon icon="mdi-chevron-down" color="primary" />
|
||||
<VMenu activator="parent" close-on-content-click>
|
||||
@@ -228,9 +231,6 @@ onMounted(() => {
|
||||
</VList>
|
||||
</VMenu>
|
||||
</IconBtn>
|
||||
<span class="text-sm">
|
||||
↑ {{ formatFileSize(cardProps.data?.upload || 0) }} / ↓ {{ formatFileSize(cardProps.data?.download || 0) }}
|
||||
</span>
|
||||
<VSpacer />
|
||||
</VCardActions>
|
||||
<StatIcon v-if="cardProps.site?.is_active" :color="statColor" />
|
||||
|
||||
@@ -16,7 +16,7 @@ const customRules = ref<CustomRule[]>([])
|
||||
const filterRuleGroups = ref<FilterRuleGroup[]>([])
|
||||
|
||||
// 种子优先规则
|
||||
const selectedTorrentPriority = ref<string>('seeder')
|
||||
const selectedTorrentPriority = ref<string[]>(['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
|
||||
@@ -389,7 +403,7 @@ onMounted(() => {
|
||||
<VIcon icon="mdi-share" />
|
||||
</VBtn>
|
||||
<VBtn color="error" variant="tonal" @click="deleteAllRules('custom')">
|
||||
<VIcon icon="mdi-delete" />
|
||||
<VIcon icon="mdi-delete-empty-outline" />
|
||||
</VBtn>
|
||||
</VBtnGroup>
|
||||
</div>
|
||||
@@ -440,7 +454,7 @@ onMounted(() => {
|
||||
<VIcon icon="mdi-share" />
|
||||
</VBtn>
|
||||
<VBtn color="error" variant="tonal" @click="deleteAllRules('group')">
|
||||
<VIcon icon="mdi-delete" />
|
||||
<VIcon icon="mdi-delete-empty-outline" />
|
||||
</VBtn>
|
||||
</VBtnGroup>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user