feat(config): 添加用户UID配置并优化秘境顺序列表初始化逻辑

- 在配置文件中添加用户UID字段用于个性化配置
- 将秘境顺序列表从数组改为Set以避免重复数据
- 实现基于UID的配置读取功能
- 添加配置文件解析逻辑支持多用户配置
- 修改返回逻辑将Set转换为数组确保兼容性
- 更新错误检查条件适配新的数据结构
This commit is contained in:
yan
2026-02-08 14:09:07 +08:00
parent b4e7310f90
commit e2d976765e
2 changed files with 30 additions and 5 deletions

View File

@@ -7,6 +7,9 @@ const config = {
manifest: {},
settings: undefined
},
user: {
uid: undefined,
},
//
path: {
manifest: "manifest.json",

View File

@@ -36,8 +36,29 @@ async function autoDomainList(autoDomainOrderList) {
* @returns {Array} 返回处理后的秘境顺序列表
*/
function initDomainOrderList(domainConfig) {
const autoFightOrderList = [] // 存储秘境顺序列表的数组
if (domainConfig){
const autoFightOrderSet = new Set() // 存储秘境顺序列表的数组
/* let te = {
order: 1, // 顺序值
autoFight: {
domainName: undefined,//秘境名称
partyName: undefined,//队伍名称
sundaySelectedValue: undefined,//周日|限时选择的值
DomainRoundNum: undefined,//副本轮数
} // 秘境信息对象
}*/
const uid = undefined
if (uid) {
const configAutoFightOrderMap = JSON.parse(file.readTextSync(config.path.domainConfig)) || new Map()
const uidConfigList = configAutoFightOrderMap.get(uid) || [];
if (uidConfigList?.length > 0) {
uidConfigList.forEach(item => {
// 将秘境顺序对象添加到列表中
autoFightOrderSet.add(item)
})
}
}
if (domainConfig) {
// 处理输入字符串:去除首尾空格,将中文逗号替换为英文逗号,然后按逗号分割
domainConfig.trim().replaceAll('', ',').split(",").forEach(
item => {
@@ -90,17 +111,18 @@ function initDomainOrderList(domainConfig) {
autoFight: autoFight // 秘境信息对象
}
// 将秘境顺序对象添加到列表中
autoFightOrderList.push(autoFightOrder)
autoFightOrderSet.add(autoFightOrder)
// autoFightOrderSet.push(autoFightOrder)
}
)
}
// 检查是否已配置秘境
if (autoFightOrderList.length <= 0) {
if (autoFightOrderSet.length <= 0) {
throw new Error("请先配置秘境配置");
}
// 返回处理后的秘境顺序列表
return autoFightOrderList;
return Array.from(autoFightOrderSet);
}
/**