mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-04-01 06:09:50 +08:00
- 在bgi_tools.js中导出pullJsonConfig和pushAllJsonConfig方法 - 在main.js中导入并集成bgi_tools配置加载逻辑 - 新增LoadType.bgi_tools分支处理远程配置拉取 - 添加settings.json配置项用于设置bgi_tools的HTTP接口地址 - 实现从远程JSON配置文件读取自动战斗计划功能
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
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
|
|
})
|
|
}
|
|
|
|
export {
|
|
pullJsonConfig,
|
|
pushAllJsonConfig
|
|
} |