mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 16:16:42 +08:00
Update AccountSettingRule.vue
This commit is contained in:
@@ -188,15 +188,11 @@ function saveCodeString(type: string, codeString: any) {
|
|||||||
// 更新数据
|
// 更新数据
|
||||||
try {
|
try {
|
||||||
if (type === 'custom') {
|
if (type === 'custom') {
|
||||||
for (const value of parsedCode) {
|
if (!checkValueValidity(parsedCode, type)) return false
|
||||||
if (!checkValueValidity(value, type)) return false
|
|
||||||
}
|
|
||||||
const newCustomRules = extractCustomRules(parsedCode) || []
|
const newCustomRules = extractCustomRules(parsedCode) || []
|
||||||
customRules.value = [...customRules.value, ...newCustomRules]
|
customRules.value = [...customRules.value, ...newCustomRules]
|
||||||
} else if (type === 'group') {
|
} else if (type === 'group') {
|
||||||
for (const value of parsedCode) {
|
if (!checkValueValidity(parsedCode, type)) return false
|
||||||
if (!checkValueValidity(value, type)) return false
|
|
||||||
}
|
|
||||||
const newFilterRuleGroups = extractFilterRuleGroups(parsedCode) || []
|
const newFilterRuleGroups = extractFilterRuleGroups(parsedCode) || []
|
||||||
filterRuleGroups.value = [...filterRuleGroups.value, ...newFilterRuleGroups]
|
filterRuleGroups.value = [...filterRuleGroups.value, ...newFilterRuleGroups]
|
||||||
} else {
|
} else {
|
||||||
@@ -241,10 +237,12 @@ function extractFilterRuleGroups(value: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据ID简单区分规则与规则组
|
// 根据ID简单区分规则与规则组
|
||||||
function checkValueValidity(value: any, type: string): boolean {
|
function checkValueValidity(values: any, type: string): boolean {
|
||||||
|
try {
|
||||||
// 允许空值存在,不影响最终的导入
|
// 允许空值存在,不影响最终的导入
|
||||||
if (!value) return true
|
if (!values) return true
|
||||||
if (!type) return false
|
if (!type) return false
|
||||||
|
for (const value of values) {
|
||||||
const keys = Object.keys(value)
|
const keys = Object.keys(value)
|
||||||
const uniqueKeys = new Set(keys)
|
const uniqueKeys = new Set(keys)
|
||||||
|
|
||||||
@@ -267,7 +265,12 @@ function checkValueValidity(value: any, type: string): boolean {
|
|||||||
console.error(`传入了不合法类型`)
|
console.error(`传入了不合法类型`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 规则变化时赋值
|
// 规则变化时赋值
|
||||||
|
|||||||
Reference in New Issue
Block a user