update setting utils
This commit is contained in:
parent
e2ed03218d
commit
c580fb7a00
1 changed files with 7 additions and 3 deletions
|
@ -17,7 +17,7 @@ export class SettingUtils {
|
||||||
settings: Map<string, ISettingItem> = new Map();
|
settings: Map<string, ISettingItem> = new Map();
|
||||||
elements: Map<string, HTMLElement> = new Map();
|
elements: Map<string, HTMLElement> = new Map();
|
||||||
|
|
||||||
constructor(plugin: Plugin, name?: string, width?: string, height?: string) {
|
constructor(plugin: Plugin, name?: string, width?: string, height?: string, callback?: (data: any) => void) {
|
||||||
this.name = name ?? 'settings';
|
this.name = name ?? 'settings';
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.file = this.name.endsWith('.json') ? this.name : `${this.name}.json`;
|
this.file = this.name.endsWith('.json') ? this.name : `${this.name}.json`;
|
||||||
|
@ -29,9 +29,13 @@ export class SettingUtils {
|
||||||
this.updateValue(key);
|
this.updateValue(key);
|
||||||
}
|
}
|
||||||
let data = this.dump();
|
let data = this.dump();
|
||||||
|
if (callback !== undefined) {
|
||||||
|
callback(data);
|
||||||
|
} else {
|
||||||
this.plugin.data[this.name] = data;
|
this.plugin.data[this.name] = data;
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue