add sample-node-config.json
This commit is contained in:
1 parent
e58ae18f79
commit
78aec1afb1
3 files changed
+19
-3
No files matched your search
+12
-2
@@ -1,4 +1,4 @@
|
||||
import { BrowserView, Menu, app, shell, dialog, BrowserWindow, MenuItem, WebContents, MenuItemConstructorOptions } from 'electron';
|
||||
import { Menu, app, dialog, BrowserWindow, MenuItem, WebContents, MenuItemConstructorOptions } from 'electron';
|
||||
import MainEventType from '../common/MainEventType';
|
||||
import { MainProcess } from './main';
|
||||
import Settings from './Settings';
|
||||
@@ -167,8 +167,18 @@ export default class AppMenu {
|
||||
}
|
||||
|
||||
private createNodeMenu() {
|
||||
const nodeItems: MenuItemConstructorOptions[] = [];
|
||||
for (let node of this.settings.nodeConfig) {
|
||||
nodeItems.push({
|
||||
label: `${node.name}(${node.desc})`,
|
||||
click: () => {
|
||||
console.log("create node", node.name);
|
||||
}
|
||||
})
|
||||
}
|
||||
return new MenuItem({
|
||||
label: "新建节点"
|
||||
label: "新建节点",
|
||||
submenu: nodeItems
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
const settingPath = 'settings.json';
|
||||
const sampleNodeConfig = 'sample-node-config.json'
|
||||
|
||||
export interface SettingsModel {
|
||||
recentWorkspaces?: string[];
|
||||
@@ -18,7 +19,7 @@ export default class Settings {
|
||||
this.settings = {
|
||||
recentWorkspaces: [],
|
||||
recentFiles: [],
|
||||
nodeConfigPath: ''
|
||||
nodeConfigPath: sampleNodeConfig,
|
||||
};
|
||||
this.save();
|
||||
}
|
||||
@@ -33,6 +34,10 @@ export default class Settings {
|
||||
get recentFiles() {
|
||||
return this.settings.recentFiles;
|
||||
}
|
||||
get nodeConfig() {
|
||||
const str = fs.readFileSync(this.nodeConfigPath, 'utf8');
|
||||
return JSON.parse(str);
|
||||
}
|
||||
|
||||
set(config: SettingsModel) {
|
||||
this.settings = {
|
||||
|
||||
Reference in new issue
Block a user