diff --git a/main.tsx b/main.tsx
index bd4bb70..6a3bcb4 100644
--- a/main.tsx
+++ b/main.tsx
@@ -8,7 +8,7 @@ let createWindow = function () {
width: 1280,
height: 800,
webPreferences: {
- // nodeIntegration: true
+ nodeIntegration: true
}
// fullscreenable:false,
// maximizable:false
@@ -18,6 +18,7 @@ let createWindow = function () {
mainWindow.on('closed', function () {
mainWindow = null
});
+ initMenu(mainWindow);
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
@@ -30,6 +31,4 @@ app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
-});
-
-initMenu();
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/src/AppMenu.ts b/src/AppMenu.ts
index b502325..aef4456 100644
--- a/src/AppMenu.ts
+++ b/src/AppMenu.ts
@@ -1,20 +1,30 @@
import { BrowserView, Menu, app, shell, dialog, BrowserWindow, MenuItem } from 'electron';
+import EventType from './EventType';
-export function initMenu() {
+export function initMenu(mainWindow: BrowserWindow) {
const menu: Menu = new Menu();
const fileMenu: MenuItem = new MenuItem({
label: "行为树",
submenu: [
- {
+ {
label: "打开文件",
- accelerator: "Ctrl+O"
+ accelerator: "Ctrl+O",
+ click: () => {
+ (async () => {
+ const res = await dialog.showOpenDialog({
+ properties: ['openFile', 'openDirectory']
+ });
+ console.log("open res", res);
+ mainWindow.webContents.send(EventType.MAIN_OPEN_FILE, res);
+ })();
+ }
},
- {
+ {
label: "打开目录",
accelerator: "Ctrl+Shift+O"
-
+
},
- { type: 'separator'},
+ { type: 'separator' },
{
label: "最近打开",
submenu: []
@@ -22,11 +32,11 @@ export function initMenu() {
{
label: "最近目录",
submenu: [
- {label: "master"},
- {label: "分支0908"},
+ { label: "master" },
+ { label: "分支0908" },
]
},
- { type: 'separator'},
+ { type: 'separator' },
{
label: "关闭",
click: () => {
diff --git a/src/Editor/index.tsx b/src/Editor/index.tsx
index 7eb293c..33b09aa 100644
--- a/src/Editor/index.tsx
+++ b/src/Editor/index.tsx
@@ -1,7 +1,23 @@
import React, { Component } from "react";
import { DatePicker } from 'antd';
+import { ipcRenderer } from 'electron';
+import EventType from "../EventType";
+
+interface EditorState {
+ workspace: string;
+}
export default class Editor extends Component {
+ state: EditorState = {
+ workspace: ''
+ }
+
+ componentDidMount() {
+ ipcRenderer.on(EventType.MAIN_OPEN_FILE, (event: any, path: any) => {
+ console.log("on", event, path);
+ })
+ }
+
render() {
return (