質問編集履歴
1
MainProcessのコードを全て記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,31 +44,65 @@
|
|
44
44
|
|
45
45
|
//MainProcess
|
46
46
|
|
47
|
-
|
47
|
+
const {BrowserWindow, app, ipcMain} = require('electron');
|
48
48
|
|
49
|
-
|
49
|
+
const path = require('path');
|
50
50
|
|
51
|
-
//ここの処理は実行される
|
52
51
|
|
52
|
+
|
53
|
+
let mainWindow;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
app.on('ready', function() {
|
58
|
+
|
59
|
+
mainWindow = new BrowserWindow({
|
60
|
+
|
61
|
+
frame: false,
|
62
|
+
|
63
|
+
width: 300,
|
64
|
+
|
65
|
+
height: 300,
|
66
|
+
|
67
|
+
webPreferences: {
|
68
|
+
|
69
|
+
nodeIntegration: true,
|
70
|
+
|
71
|
+
contextIsolation: false
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
});
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
mainWindow.loadURL('htmlFilePath');//htmlFilePathは任意の文字列
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
mainWindow.on('closed', function() {
|
84
|
+
|
85
|
+
//iframeを含むとここが実行されない
|
86
|
+
|
53
|
-
mainWindow
|
87
|
+
mainWindow = null;
|
88
|
+
|
89
|
+
});
|
90
|
+
|
91
|
+
});
|
92
|
+
|
93
|
+
app.on('window-all-closed', function () {
|
94
|
+
|
95
|
+
app.quit();
|
54
96
|
|
55
97
|
});
|
56
98
|
|
57
99
|
|
58
100
|
|
59
|
-
main
|
101
|
+
ipcMain.on('mainwindow_close', () => {
|
60
102
|
|
61
|
-
//ここ
|
103
|
+
//ここは実行される
|
62
104
|
|
63
|
-
mainWindow
|
105
|
+
mainWindow.close();
|
64
|
-
|
65
|
-
});
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
app.on('window-all-closed', () => {
|
70
|
-
|
71
|
-
app.quit();
|
72
106
|
|
73
107
|
});
|
74
108
|
|