rebuild project
This commit is contained in:
1 parent
69a284cc16
commit
84e1e376b9
9 files changed
+8
-7
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import { BrowserView, Menu, app, shell, dialog, BrowserWindow, MenuItem } from 'electron';
|
||||
import EventType from '../common/EventType';
|
||||
|
||||
export function initMenu(mainWindow: BrowserWindow) {
|
||||
const menu: Menu = new Menu();
|
||||
const fileMenu: MenuItem = new MenuItem({
|
||||
label: "行为树",
|
||||
submenu: [
|
||||
{
|
||||
label: "打开文件",
|
||||
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' },
|
||||
{
|
||||
label: "最近打开",
|
||||
submenu: []
|
||||
},
|
||||
{
|
||||
label: "最近目录",
|
||||
submenu: [
|
||||
{ label: "master" },
|
||||
{ label: "分支0908" },
|
||||
]
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: "关闭",
|
||||
click: () => {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const toolsMenu: MenuItem = new MenuItem({
|
||||
label: "开发工具",
|
||||
submenu: [
|
||||
{
|
||||
label: "重载",
|
||||
accelerator: "Ctrl+R",
|
||||
click: (_, browserWindow) => {
|
||||
browserWindow.reload();
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "打开控制台",
|
||||
accelerator: "Ctrl+Shift+I",
|
||||
click: (_, browserWindow) => {
|
||||
browserWindow.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
menu.append(fileMenu);
|
||||
menu.append(toolsMenu);
|
||||
|
||||
Menu.setApplicationMenu(menu);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { app, BrowserWindow, Menu, MenuItem, dialog, nativeTheme } from 'electron';
|
||||
import {initMenu} from './AppMenu'
|
||||
|
||||
let mainWindow: BrowserWindow = null;
|
||||
nativeTheme.themeSource = 'dark';
|
||||
let createWindow = function () {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
// fullscreenable:false,
|
||||
// maximizable:false
|
||||
});
|
||||
// mainWindow.webContents.openDevTools();
|
||||
mainWindow.loadFile('index.html');
|
||||
mainWindow.on('closed', function () {
|
||||
mainWindow = null
|
||||
});
|
||||
initMenu(mainWindow);
|
||||
}
|
||||
app.on('ready', createWindow)
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (mainWindow === null) {
|
||||
createWindow()
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user