添加setAndSave方法作为设置参数并保存

This commit is contained in:
浔阳陌客 2024-04-06 01:44:54 +08:00
parent f9ea1bec3f
commit 44d61785cf

View file

@ -80,6 +80,20 @@ export class SettingUtils {
this.updateElementFromValue(key); this.updateElementFromValue(key);
} }
} }
/**
* Set and save setting item value
* If you want to set and save immediately you can use this method
* @param key key name
* @param value value
*/
async setAndSave(key: string, value: any) {
let item = this.settings.get(key);
if (item) {
item.value = value;
this.updateElementFromValue(key);
await this.save()
}
}
/** /**
* Disable setting item * Disable setting item