fix[config]support overwrite by user

This commit is contained in:
汉广 committed 2024-07-24 14:25:58 +08:00
1 parent 03bc844ad0
commit 28927f950d
3 files changed
+8 -4

No files matched your search

+5 -1
View File
@@ -73,8 +73,12 @@ export class ConfigBase<T> {
}
}
save(config: T) {
save(config: T, overwrite: boolean = false) {
Object.assign(this, config);
if (overwrite) {
// 用户要求强制写入,则变更当前文件为目标文件
this.pathName = `${selfInfo.uin}`
}
const configPath = this.getConfigPath(this.pathName);
try {
fs.writeFileSync(configPath, JSON.stringify(this, this.getKeys(), 2));