mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-05-18 09:46:54 +08:00
feat(bgi_tools): 添加BGI工具HTTP配置拉取推送功能
- 实现pullJsonConfig函数用于拉取指定uid的JSON配置数据 - 实现pushAllJsonConfig函数用于推送全部JSON配置数据 - 在配置中添加bgi_tools相关API接口地址配置项 - 新增bgi_tools加载类型支持并添加到加载映射表中 - 更新加载模式界面选项增加bgi_tools加载选项 - 修改加载顺序逻辑支持按优先级排序 - 修复自动域参数初始化时副本轮数传递问题 - 更新多选框组件标签文本增加http获取配置说明 - 添加OCR区域资源释放后的空行格式化调整
This commit is contained in:
@@ -7,6 +7,12 @@ const config = {
|
||||
// load_uid_config: false,
|
||||
loads: [],//加载方式list
|
||||
},
|
||||
bgi_tools: {
|
||||
api: {
|
||||
httpPullJsonConfig: undefined,
|
||||
httpPushAllJsonConfig: undefined,
|
||||
}
|
||||
},
|
||||
info: {
|
||||
key: undefined,//密钥
|
||||
manifest: {},
|
||||
@@ -38,6 +44,7 @@ const config = {
|
||||
const LoadType = Object.freeze({
|
||||
uid: 'uid',//uid加载
|
||||
input: 'input',//input加载
|
||||
bgi_tools: 'bgi_tools',//input加载
|
||||
fromValue(value) {
|
||||
return Object.keys(this).find(key => this[key] === value);
|
||||
}
|
||||
@@ -45,6 +52,7 @@ const LoadType = Object.freeze({
|
||||
const LoadMap = new Map([
|
||||
['UID加载', LoadType.uid],
|
||||
['输入加载', LoadType.input],
|
||||
['bgi_tools加载', LoadType.bgi_tools],
|
||||
])
|
||||
|
||||
/**
|
||||
@@ -433,7 +441,23 @@ async function initConfig() {
|
||||
throw new Error("配置文件缺失或读取异常!")
|
||||
}
|
||||
let loadList = await getValueByMultiCheckboxName('auto_load') || []
|
||||
const loads = loadList.map(item => LoadMap.get(item))
|
||||
const loads = loadList.map(item => {
|
||||
const load = LoadMap.get(item);
|
||||
let order = 1
|
||||
switch (load) {
|
||||
case LoadType.input:
|
||||
order = 1;
|
||||
break;
|
||||
case LoadType.uid:
|
||||
order = 2;
|
||||
break;
|
||||
case LoadType.bgi_tools:
|
||||
order = 3;
|
||||
break;
|
||||
}
|
||||
return {load: load, order: order}
|
||||
})
|
||||
loads.sort((a, b) => a.order - b.order)
|
||||
config.domain.loads = loads
|
||||
config.user.uid = await ocrUid()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {ocrUid} from './utils/uid';
|
||||
*/
|
||||
async function autoDomain(autoFight) {
|
||||
// 创建秘境参数对象,初始化值为0
|
||||
let domainParam = new AutoDomainParam(0);
|
||||
let domainParam = new AutoDomainParam(autoFight.DomainRoundNum);
|
||||
//秘境名称
|
||||
domainParam.DomainName = autoFight.domainName || domainParam.DomainName;
|
||||
//队伍名称
|
||||
@@ -16,7 +16,7 @@ async function autoDomain(autoFight) {
|
||||
//周日|限时选择的值
|
||||
domainParam.SundaySelectedValue = autoFight.sundaySelectedValue || domainParam.SundaySelectedValue;
|
||||
//副本轮数
|
||||
domainParam.DomainRoundNum = autoFight.DomainRoundNum || domainParam.DomainRoundNum;
|
||||
// domainParam.domainRoundNum = autoFight.DomainRoundNum || domainParam.DomainRoundNum;
|
||||
await dispatcher.RunAutoDomainTask(domainParam);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,9 @@ async function initDomainOrderList(domainConfig) {
|
||||
} // 秘境信息对象
|
||||
}*/
|
||||
// let Load = LoadType.uid
|
||||
|
||||
for (const Load of config.domain.loads) {
|
||||
await loadMode(Load, autoFightOrderSet, domainConfig);
|
||||
await loadMode(Load.load, autoFightOrderSet, domainConfig);
|
||||
}
|
||||
|
||||
// 检查是否已配置秘境
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
{
|
||||
"name": "auto_load",
|
||||
"type": "multi-checkbox",
|
||||
"label": "加载模式\n全选时相同的配置输入加载会覆盖UID加载\n自动秘境计划配置(属于输入加载)\nconfig/domain_config.json(属于UID加载)",
|
||||
"option": ["输入加载","UID加载"] ,
|
||||
"label": "加载模式\n全选时相同的配置输入加载会覆盖UID加载\n自动秘境计划配置(属于输入加载)\nconfig/domain_config.json(属于UID加载)\nhttp获取配置(属于bgi_tools加载)",
|
||||
"option": ["输入加载","UID加载","bgi_tools加载"] ,
|
||||
"default": ["输入加载","UID加载"]
|
||||
},
|
||||
{
|
||||
|
||||
48
repo/js/AutoPlanDomain/utils/bgi_tools.js
Normal file
48
repo/js/AutoPlanDomain/utils/bgi_tools.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import {config} from "../config/config";
|
||||
|
||||
/**
|
||||
* 拉取对应uid的Json数据
|
||||
* @param uid
|
||||
* @param http_api
|
||||
* @returns {Promise<HttpResponse>}
|
||||
*/
|
||||
async function pullJsonConfig(uid, http_api = config.bgi_tools.api.httpPullJsonConfig) {
|
||||
const result = http.request("GET", http_api, JSON.stringify({
|
||||
uid: uid,
|
||||
})
|
||||
// , JSON.stringify({"Content-Type": "application/json"})
|
||||
).then(res => {
|
||||
log.debug(`[{0}]res=>{1}`, 'next', JSON.stringify(res))
|
||||
if (res.status_code === 200 && res.body) {
|
||||
let result_json = JSON.parse(res.body);
|
||||
if (result_json?.code === 200) {
|
||||
return result_json?.data
|
||||
}
|
||||
throw new Error("请求失败,error:" + result_json?.message)
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送全部Json数据
|
||||
* @param Json
|
||||
* @param http_api
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function pushAllJsonConfig(Json = "[]", http_api = config.bgi_tools.api.httpPushAllJsonConfig) {
|
||||
const result = http.request("POST", http_api, Json
|
||||
, JSON.stringify({"Content-Type": "application/json"})
|
||||
).then(res => {
|
||||
log.debug(`[{0}]res=>{1}`, 'next', JSON.stringify(res))
|
||||
if (res.status_code === 200 && res.body) {
|
||||
let result_json = JSON.parse(res.body);
|
||||
if (result_json?.code === 200) {
|
||||
return result_json?.data
|
||||
}
|
||||
throw new Error("请求失败,error:" + result_json?.message)
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
}
|
||||
@@ -28,6 +28,7 @@ async function ocrRegion(x = 0,
|
||||
region3.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
ocrRegion
|
||||
}
|
||||
@@ -28,4 +28,4 @@ async function ocrUid() {
|
||||
|
||||
export {
|
||||
ocrUid,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user