fix: 修复攻略

This commit is contained in:
bietiaop 2024-07-27 12:49:16 +08:00
parent 2f83ea81a4
commit 075a6d4fd0
4 changed files with 101 additions and 90 deletions

View file

@ -24,7 +24,7 @@ const ZZZ_SUIT_PATH = path.join(imageResourcesPath, 'suit');
* @param {string} savePath 保存路径
* @returns
*/
const downloadFile = async (url, savePath) => {
export const downloadFile = async (url, savePath) => {
const _download = async (url, savePath, retry = 0) => {
// 重试次数超过 5 次则返回 null
if (retry > 5) {

View file

@ -153,12 +153,31 @@ class Setting {
/**
* 设置对应模块用户配置
* @param {'atlas'|'config'|'gacha'|'panel'} app
* @param {'atlas'|'config'|'gacha'|'panel'|'guide'} app
* @param {object} obj
* @returns
*/
setConfig(app, obj) {
return this.setYaml(app, 'config', { ...this.getdefSet(app), ...obj });
// 先获取默认配置
const defSet = this.getdefSet(app);
// 再获取用户配置
const config = this.getConfig(app);
return this.setYaml(app, 'config', { ...defSet, ...config, ...obj });
}
/**
* 设置对应模块用户配置
* @param {'atlas'|'config'|'gacha'|'panel'|'guide'} app
* @param {string} key
* @param {string} value
* @returns {boolean}
*/
setSingleConfig(app, key, value) {
// 先获取默认配置
const defSet = this.getdefSet(app);
const config = this.getConfig(app);
config[key] = value;
return this.setYaml(app, 'config', { ...defSet, ...config });
}
// 将对象写入YAML文件