feat(AutoPlanDomain): 添加自动秘境计划配置功能

- 在配置文件中添加manifest对象结构
- 为domainList添加默认空数组配置避免解析错误
- 重构order解析逻辑增加空值和类型验证保护
- 添加自动秘境计划配置设置项支持文本输入
- 实现配置初始化异步加载功能
- 增加多复选框映射表获取函数注释文档
This commit is contained in:
yan
2026-02-08 13:15:21 +08:00
parent f4266d98ea
commit 04175a1da7
3 changed files with 26 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ const config = {
config: ''
},
info: {
manifest:{},
manifest: {},
settings: undefined
},
//
@@ -63,6 +63,7 @@ async function initSettings() {
// 返回设置对象
return settingsJson
}
/**
* 获取多复选框的映射表
* 该函数会从初始化的设置中提取所有类型为"multi-checkbox"的条目,
@@ -110,6 +111,7 @@ async function getValueByMultiCheckboxName(name) {
log.debug("values={key}", JSON.stringify(values))
return values
}
async function initConfig() {
/* const domainList = [
{
@@ -359,7 +361,12 @@ async function initConfig() {
}
]*/
const domainList = JSON.parse(file.readTextSync(config.path.domain)) || []
const domainList = JSON.parse(file.readTextSync(config.path.domain)) || [{
name: undefined,
type: undefined,
hasOrder: false,
list: []
}]
config.domainList.push(...domainList)

View File

@@ -53,7 +53,15 @@ function initDomainOrderList(domainConfig) {
let domainName = arr[1];
let DomainRoundNum = arr[2];
let sundaySelectedValue = arr[3];
let order = parseInt(arr[4]+"");
let order = (() => {
const rawOrder = arr[4]; // 获取原始值
if (rawOrder == null || String(rawOrder).trim() === "") {
return 0; // 若为空或无效值,默认返回 0
}
const parsedOrder = parseInt(String(rawOrder).trim(), 10); // 转换为整数
return isNaN(parsedOrder) ? 0 : parsedOrder; // 若转换失败,返回默认值 0
})();
if (!config.domainNames.has(domainName)) {
//秘境名称没有记录 查询是否是物品名称

View File

@@ -1 +1,8 @@
[]
[
{
"name": "domain_config",
"type": "input-text",
"label": "自动秘境计划配置\n语法:队伍名称|秘境名称/刷取物品名称|刷几轮|限时/周日(1-3和本体的一致)|执行顺序(越大越先执行),...\n(无配置可留空如||唯有秘境名称配置不可为空)\n如: 速刷|苍白的遗荣|1||9",
"default": ""
},
]