0
|
1 "use strict";
|
|
2
|
|
3 const electron = require("electron");
|
|
4 const app = electron.app;
|
|
5 const Menu = electron.Menu;
|
|
6 const BrowserWindow = electron.BrowserWindow;
|
|
7 let mainWindow;
|
|
8 let locate;
|
|
9
|
|
10 // 全てのウィンドウが閉じたら終了
|
|
11 app.on('window-all-closed', function() {
|
|
12 if (process.platform != 'darwin') {
|
|
13 app.quit();
|
|
14 }
|
|
15 });
|
|
16
|
|
17 // app.on('open-file', function() {
|
|
18
|
|
19 // });
|
|
20
|
|
21 // Electronの初期化完了後に実行
|
|
22 app.on('ready', function() {
|
|
23 // メイン画面の表示。ウィンドウの幅、高さを指定できる
|
|
24 mainWindow = new BrowserWindow({
|
|
25 width: 800,
|
|
26 height: 600,
|
|
27 maxWidth: 800,
|
|
28 maxHeight: 600,
|
|
29 disableAutoHideCursor: true,
|
|
30 resizable: true,
|
|
31 autoHideMenuBar: true,
|
|
32 frame: false,
|
|
33 webPreferences: {},
|
|
34 });
|
|
35
|
|
36 var inmenu = [
|
|
37 {submenu: [
|
|
38 { role: 'quit',},
|
|
39 ]},
|
1
|
40 {label: 'Edit',
|
|
41 submenu: [
|
|
42 {role: 'cut',},
|
|
43 {role: 'copy',},
|
|
44 {role: 'paste',},
|
|
45 {role: 'selectAll',},
|
|
46 {role: 'delete',},
|
0
|
47
|
1
|
48 ]},
|
0
|
49 {label: 'View',
|
|
50 submenu: [
|
1
|
51 {role: 'reload',},
|
0
|
52 { role: 'minimize',},
|
|
53 { role: 'zoomin',},
|
|
54 { role: 'zoomout',},
|
|
55 { role: 'togglefullscreen'},
|
1
|
56 {role: 'hide',},
|
|
57
|
0
|
58 ]}
|
|
59 ];
|
|
60
|
|
61 const menu = Menu.buildFromTemplate(inmenu);
|
|
62 Menu.setApplicationMenu(menu);
|
|
63
|
|
64
|
|
65 locate = 'file://' + __dirname + '/index.html';
|
|
66 // if (process.argv[2] !== undefined) {
|
|
67 // locate = process.argv[2];
|
|
68 // }
|
|
69
|
|
70 mainWindow.loadURL(locate);
|
|
71 // ウィンドウが閉じられたらアプリも終了
|
|
72 mainWindow.on('closed', function() {
|
|
73 mainWindow = null;
|
|
74 });
|
|
75 });
|