mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-29 05:39:51 +08:00
feat(bgi_tools): 添加全部国家配置推送功能
- 新增 pushAllCountryConfig 函数用于推送国家配置数据 - 配置文件中添加 httpPushAllCountryConfig API 地址配置项 - 添加 countryList.json 文件存储国家列表数据 - 在 main.js 中集成国家配置推送逻辑 - 设置文件中添加国家配置推送API设置选项 - 完善相关依赖注入和配置初始化流程
This commit is contained in:
@@ -18,6 +18,7 @@ const config = {
|
||||
api: {
|
||||
httpPullJsonConfig: undefined,
|
||||
httpPushAllJsonConfig: undefined,
|
||||
httpPushAllCountryConfig: undefined,
|
||||
},
|
||||
open: {open_push: false}
|
||||
},
|
||||
@@ -39,7 +40,8 @@ const config = {
|
||||
path: {
|
||||
manifest: "manifest.json",
|
||||
domain: "config/domain.json",
|
||||
runConfig: "config/run_config.json"
|
||||
runConfig: "config/run_config.json",
|
||||
countryList: "config/countryList.json"
|
||||
},
|
||||
//所有秘境信息
|
||||
domainList: [],
|
||||
@@ -184,6 +186,7 @@ async function initConfig() {
|
||||
config.bgi_tools.token.value = list[1]
|
||||
config.bgi_tools.api.httpPullJsonConfig = settings.bgi_tools_http_pull_json_config
|
||||
config.bgi_tools.api.httpPushAllJsonConfig = settings.bgi_tools_http_push_all_json_config
|
||||
config.bgi_tools.api.httpPushAllCountryConfig = settings.bgi_tools_http_push_all_country_config
|
||||
config.bgi_tools.open.open_push = settings.bgi_tools_open_push
|
||||
log.debug(`|bgi_tools:{1}`, JSON.stringify(config.bgi_tools))
|
||||
// const text = file.readTextSync(config.path.domain);
|
||||
|
||||
9
repo/js/AutoPlan/config/countryList.json
Normal file
9
repo/js/AutoPlan/config/countryList.json
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
"蒙德",
|
||||
"璃月",
|
||||
"稻妻",
|
||||
"须弥",
|
||||
"枫丹",
|
||||
"纳塔",
|
||||
"挪德卡莱"
|
||||
]
|
||||
@@ -1,7 +1,7 @@
|
||||
import {config, initConfig, initSettings, LoadType} from './config/config';
|
||||
import {ocrUid} from './utils/uid';
|
||||
import {getDayOfWeek, outDomainUI, throwError} from './utils/tool';
|
||||
import {pullJsonConfig, pushAllJsonConfig} from './utils/bgi_tools';
|
||||
import {pullJsonConfig, pushAllCountryConfig, pushAllJsonConfig} from './utils/bgi_tools';
|
||||
import {ocrPhysical} from "./utils/physical";
|
||||
|
||||
/**
|
||||
@@ -453,6 +453,7 @@ async function main() {
|
||||
if (config.bgi_tools.open.open_push) {
|
||||
log.info(`开始推送bgi_tools配置`)
|
||||
await pushAllJsonConfig(JSON.parse(file.readTextSync(config.path.domain)), config.bgi_tools.api.httpPushAllJsonConfig, config.bgi_tools.token)
|
||||
await pushAllCountryConfig(JSON.parse(file.readTextSync(config.path.countryList)), config.bgi_tools.api.httpPushAllCountryConfig, config.bgi_tools.token)
|
||||
}
|
||||
// 获取配置
|
||||
let runConfig = config.run.config;
|
||||
|
||||
@@ -51,6 +51,12 @@
|
||||
"label": "bgi_tools推送全部配置api(去看文档)",
|
||||
"default": "http://127.0.0.1:8081/bgi/auto/plan/domain/json/all"
|
||||
},
|
||||
{
|
||||
"name": "bgi_tools_http_push_all_country_config",
|
||||
"type": "input-text",
|
||||
"label": "bgi_tools推送全部国家配置api(去看文档)",
|
||||
"default": "http://127.0.0.1:8081/bgi/auto/plan/country/all"
|
||||
},
|
||||
{
|
||||
"name": "bgi_tools_token",
|
||||
"type": "input-text",
|
||||
|
||||
@@ -47,7 +47,34 @@ async function pushAllJsonConfig(list = [], http_api,token={name: "Authorization
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送全部国家Json数据
|
||||
* @param list
|
||||
* @param http_api
|
||||
* @param token
|
||||
* @returns {Promise<undefined|*>}
|
||||
*/
|
||||
async function pushAllCountryConfig(list = [], http_api,token={name: "Authorization", value: ''}) {
|
||||
log.info(`list:{1},http:{2}`, list, http_api)
|
||||
let value = {
|
||||
"Content-Type": "application/json",
|
||||
[token.name]: token.value
|
||||
};
|
||||
|
||||
const res = await http.request("POST", http_api, JSON.stringify({json: JSON.stringify(list)}), JSON.stringify(value))
|
||||
|
||||
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
|
||||
pushAllJsonConfig,
|
||||
pushAllCountryConfig
|
||||
}
|
||||
Reference in New Issue
Block a user