MainProcess add global val settings
This commit is contained in:
1 parent
d0690f0398
commit
23f4795562
5 files changed
+37
-22
No files matched your search
+16
-12
@@ -25,18 +25,7 @@ const sampleNodeClassify: BehaviorNodeClassify[] = [
|
||||
export default class Settings {
|
||||
private settings: SettingsModel;
|
||||
constructor() {
|
||||
if (fs.existsSync(settingPath)) {
|
||||
const str = fs.readFileSync(settingPath, 'utf8');
|
||||
this.settings = JSON.parse(str);
|
||||
} else {
|
||||
this.settings = {
|
||||
recentWorkspaces: [],
|
||||
recentFiles: [],
|
||||
nodeConfigPath: sampleNodeConfig,
|
||||
nodeClassify: sampleNodeClassify,
|
||||
};
|
||||
this.save();
|
||||
}
|
||||
this.load();
|
||||
}
|
||||
|
||||
get nodeConfigPath() {
|
||||
@@ -65,6 +54,21 @@ export default class Settings {
|
||||
this.save();
|
||||
}
|
||||
|
||||
load() {
|
||||
if (fs.existsSync(settingPath)) {
|
||||
const str = fs.readFileSync(settingPath, 'utf8');
|
||||
this.settings = JSON.parse(str);
|
||||
} else {
|
||||
this.settings = {
|
||||
recentWorkspaces: [],
|
||||
recentFiles: [],
|
||||
nodeConfigPath: sampleNodeConfig,
|
||||
nodeClassify: sampleNodeClassify,
|
||||
};
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
fs.writeFileSync(settingPath, JSON.stringify(this.settings, null, 2));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user