質問編集履歴
1
MainProcessのコードを全て記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,20 +21,37 @@
|
|
21
21
|
|
22
22
|
```javascript
|
23
23
|
//MainProcess
|
24
|
-
|
24
|
+
const {BrowserWindow, app, ipcMain} = require('electron');
|
25
|
-
|
25
|
+
const path = require('path');
|
26
|
-
//ここの処理は実行される
|
27
|
-
mainWindow.close();
|
28
|
-
});
|
29
26
|
|
27
|
+
let mainWindow;
|
28
|
+
|
29
|
+
app.on('ready', function() {
|
30
|
+
mainWindow = new BrowserWindow({
|
31
|
+
frame: false,
|
32
|
+
width: 300,
|
33
|
+
height: 300,
|
34
|
+
webPreferences: {
|
35
|
+
nodeIntegration: true,
|
36
|
+
contextIsolation: false
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
mainWindow.loadURL('htmlFilePath');//htmlFilePathは任意の文字列
|
41
|
+
|
30
|
-
mainWindow.on('closed', ()
|
42
|
+
mainWindow.on('closed', function() {
|
31
|
-
|
43
|
+
//iframeを含むとここが実行されない
|
32
|
-
|
44
|
+
mainWindow = null;
|
45
|
+
});
|
33
46
|
});
|
34
|
-
|
35
|
-
app.on('window-all-closed', ()
|
47
|
+
app.on('window-all-closed', function () {
|
36
48
|
app.quit();
|
37
49
|
});
|
50
|
+
|
51
|
+
ipcMain.on('mainwindow_close', () => {
|
52
|
+
//ここは実行される
|
53
|
+
mainWindow.close();
|
54
|
+
});
|
38
55
|
```
|
39
56
|
|
40
57
|
|