質問編集履歴
3
ソースコードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,10 +40,6 @@
|
|
40
40
|
|
41
41
|
</head>
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
43
|
<body>
|
48
44
|
|
49
45
|
<nav class="navbar bg-primary mb-4">
|
@@ -64,36 +60,268 @@
|
|
64
60
|
|
65
61
|
</div>
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
63
|
<script>
|
72
64
|
|
65
|
+
const { remote } = require('electron');
|
66
|
+
|
73
|
-
|
67
|
+
const { BrowserWindow } = remote;
|
74
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
75
|
-
|
73
|
+
function doit() {
|
76
|
-
|
74
|
+
|
77
|
-
|
75
|
+
let win = new BrowserWindow({
|
76
|
+
|
78
|
-
|
77
|
+
width: 400,
|
78
|
+
|
79
|
+
height: 300,
|
80
|
+
|
79
|
-
|
81
|
+
webPreferences: {
|
82
|
+
|
80
|
-
|
83
|
+
nodeIntegration: true,
|
84
|
+
|
81
|
-
t
|
85
|
+
enableRemoteModule: true
|
82
|
-
|
83
|
-
|
86
|
+
|
84
|
-
|
85
|
-
|
87
|
+
}
|
86
|
-
|
88
|
+
|
87
|
-
|
89
|
+
});
|
90
|
+
|
88
|
-
|
91
|
+
win.loadFile('index.html');
|
92
|
+
|
93
|
+
document.querySelector('#msg').textContent
|
94
|
+
|
95
|
+
= 'Create new window!';
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
</script>
|
100
|
+
|
89
|
-
|
101
|
+
</body>
|
102
|
+
|
103
|
+
</html>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```javascript
|
112
|
+
|
113
|
+
index.js
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
const { app, Menu, BrowserWindow } = require('electron');
|
118
|
+
|
119
|
+
const path = require('path');
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
function createWindow () {
|
126
|
+
|
127
|
+
win = new BrowserWindow({
|
128
|
+
|
129
|
+
width: 400,
|
130
|
+
|
131
|
+
height: 300,
|
132
|
+
|
133
|
+
webPreferences: {
|
134
|
+
|
135
|
+
nodeIntegration: true,
|
136
|
+
|
137
|
+
enableRemoteModule: true
|
90
138
|
|
91
139
|
}
|
92
140
|
|
141
|
+
});
|
142
|
+
|
143
|
+
win.loadFile('index.html');
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
function createMenu() {
|
152
|
+
|
153
|
+
let menu_temp = [
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
label: 'File',
|
158
|
+
|
159
|
+
submenu: [
|
160
|
+
|
161
|
+
{label: 'New', click: ()=>{
|
162
|
+
|
163
|
+
console.log('New menu.');
|
164
|
+
|
165
|
+
createWindow();
|
166
|
+
|
167
|
+
}},
|
168
|
+
|
169
|
+
{label: 'File', click: ()=>{
|
170
|
+
|
171
|
+
console.log('File menu.');
|
172
|
+
|
173
|
+
createWindow();
|
174
|
+
|
175
|
+
}},
|
176
|
+
|
177
|
+
{role: 'close'},
|
178
|
+
|
179
|
+
{type: 'separator'},
|
180
|
+
|
181
|
+
{role: 'quit'}
|
182
|
+
|
183
|
+
]
|
184
|
+
|
185
|
+
},
|
186
|
+
|
187
|
+
{role: 'editMenu'},
|
188
|
+
|
189
|
+
{role: 'viewMenu'},
|
190
|
+
|
191
|
+
{role:'windowMenu'},
|
192
|
+
|
193
|
+
{label: 'Help', submenu: [
|
194
|
+
|
195
|
+
{role: 'about'},
|
196
|
+
|
197
|
+
{type: 'separator'},
|
198
|
+
|
199
|
+
{role: 'reload'},
|
200
|
+
|
201
|
+
{role: 'zoomIn'},
|
202
|
+
|
203
|
+
{role: 'zoomOut'}
|
204
|
+
|
205
|
+
]}
|
206
|
+
|
207
|
+
];
|
208
|
+
|
209
|
+
let menu = Menu.buildFromTemplate(menu_temp);
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
Menu.setApplicationMenu(menu);
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
createMenu();
|
222
|
+
|
223
|
+
app.whenReady().then(createWindow);
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
```
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
・Monaca移行用プログラム(テンプレートは「最小限のテンプレート」を使用しております。)
|
232
|
+
|
233
|
+
```html
|
234
|
+
|
235
|
+
index.html
|
236
|
+
|
237
|
+
<!DOCTYPE HTML>
|
238
|
+
|
239
|
+
<html>
|
240
|
+
|
241
|
+
<head>
|
242
|
+
|
243
|
+
<meta charset="utf-8">
|
244
|
+
|
245
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
246
|
+
|
247
|
+
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
|
248
|
+
|
249
|
+
<script src="components/loader.js"></script>
|
250
|
+
|
251
|
+
<link rel="stylesheet" href="components/loader.css">
|
252
|
+
|
253
|
+
<link rel="stylesheet" href="css/style.css">
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
|
258
|
+
|
259
|
+
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
260
|
+
|
261
|
+
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
|
262
|
+
|
263
|
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
264
|
+
|
265
|
+
</head>
|
266
|
+
|
267
|
+
<body>
|
268
|
+
|
269
|
+
<nav class="navbar bg-primary mb-4">
|
270
|
+
|
271
|
+
<h1 class="display-4 text-light">Sample-app</h1>
|
272
|
+
|
273
|
+
</nav>
|
274
|
+
|
275
|
+
<div class="container">
|
276
|
+
|
277
|
+
<p id="msg">please click button.</p>
|
278
|
+
|
279
|
+
<button class="btn btn-primary"onclick="doit()">
|
280
|
+
|
281
|
+
Click
|
282
|
+
|
283
|
+
</button>
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
<script>
|
288
|
+
|
289
|
+
const { remote } = require('electron');
|
290
|
+
|
291
|
+
const { BrowserWindow } = remote;
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
function doit() {
|
298
|
+
|
299
|
+
let win = new BrowserWindow({
|
300
|
+
|
301
|
+
width: 400,
|
302
|
+
|
303
|
+
height: 300,
|
304
|
+
|
305
|
+
webPreferences: {
|
306
|
+
|
307
|
+
nodeIntegration: true,
|
308
|
+
|
309
|
+
enableRemoteModule: true
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
});
|
314
|
+
|
315
|
+
win.loadFile('index.html');
|
316
|
+
|
317
|
+
document.querySelector('#msg').textContent
|
318
|
+
|
319
|
+
= 'Create new window!';
|
320
|
+
|
321
|
+
}
|
322
|
+
|
93
323
|
</script>
|
94
324
|
|
95
|
-
|
96
|
-
|
97
325
|
</body>
|
98
326
|
|
99
327
|
</html>
|
@@ -128,9 +356,9 @@
|
|
128
356
|
|
129
357
|
webPreferences: {
|
130
358
|
|
359
|
+
nodeIntegration: true,
|
360
|
+
|
131
|
-
enableRemoteModule: true
|
361
|
+
enableRemoteModule: true
|
132
|
-
|
133
|
-
preload: path.join(app.getAppPath(), 'preload.js')
|
134
362
|
|
135
363
|
}
|
136
364
|
|
@@ -222,295 +450,23 @@
|
|
222
450
|
|
223
451
|
```
|
224
452
|
|
225
|
-
```javascript
|
226
|
-
|
227
|
-
preload.js
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
const { remote } = require('electron');
|
232
|
-
|
233
|
-
const { dialog } = remote;
|
234
|
-
|
235
|
-
const { ipcRenderer } = require('electron');
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
window.remote = remote;
|
242
|
-
|
243
|
-
window.dialog = dialog;
|
244
|
-
|
245
|
-
window.ipcRenderer = ipcRenderer;
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
```
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
・Monaca移行用プログラム(テンプレートは「最小限のテンプレート」を使用しております。)
|
256
|
-
|
257
|
-
```html
|
258
|
-
|
259
|
-
index.html
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
<!DOCTYPE HTML>
|
264
|
-
|
265
|
-
<html>
|
266
|
-
|
267
|
-
<head>
|
268
|
-
|
269
|
-
<meta charset="utf-8">
|
270
|
-
|
271
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
272
|
-
|
273
|
-
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: content: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
|
274
|
-
|
275
|
-
<script src="components/loader.js"></script>
|
276
|
-
|
277
|
-
<link rel="stylesheet" href="components/loader.css">
|
278
|
-
|
279
|
-
<link rel="stylesheet" href="css/style.css">
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
|
284
|
-
|
285
|
-
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
286
|
-
|
287
|
-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
|
288
|
-
|
289
|
-
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
290
|
-
|
291
|
-
</head>
|
292
|
-
|
293
|
-
<body>
|
294
|
-
|
295
|
-
<nav class="navbar bg-primary mb-4">
|
296
|
-
|
297
|
-
<h1 class="display-4 text-light">Sample-app</h1>
|
298
|
-
|
299
|
-
</nav>
|
300
|
-
|
301
|
-
<div class="container">
|
302
|
-
|
303
|
-
<p id="msg">please click button.</p>
|
304
|
-
|
305
|
-
<button class="btn btn-primary"onclick="doit()">
|
306
|
-
|
307
|
-
Click
|
308
|
-
|
309
|
-
</button>
|
310
|
-
|
311
|
-
</div>
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
<script>
|
318
|
-
|
319
|
-
const BrowserWindow = window.remote.BrowserWindow;
|
320
|
-
|
321
|
-
function doit() {
|
322
|
-
|
323
|
-
let w = remote.getCurrentWindow();
|
324
|
-
|
325
|
-
let re = dialog.showMessageBox(w, {
|
326
|
-
|
327
|
-
title:'Message',
|
328
|
-
|
329
|
-
message:'これがメッセージボックスの表示です。',
|
330
|
-
|
331
|
-
detail: 'OKすると閉じます。'
|
332
|
-
|
333
|
-
});
|
334
|
-
|
335
|
-
console.log(re);
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
</script>
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
</body>
|
344
|
-
|
345
|
-
</html>
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
```
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
```javascript
|
354
|
-
|
355
|
-
index.js
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
const { app, Menu, BrowserWindow } = require('electron');
|
360
|
-
|
361
|
-
const path = require('path');
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
function createWindow () {
|
368
|
-
|
369
|
-
win = new BrowserWindow({
|
370
|
-
|
371
|
-
width: 400,
|
372
|
-
|
373
|
-
height: 300,
|
374
|
-
|
375
|
-
webPreferences: {
|
376
|
-
|
377
|
-
enableRemoteModule: true,
|
378
|
-
|
379
|
-
preload: path.join(app.getAppPath(), 'preload.js')
|
380
|
-
|
381
|
-
}
|
382
|
-
|
383
|
-
});
|
384
|
-
|
385
|
-
win.loadFile('index.html');
|
386
|
-
|
387
|
-
}
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
function createMenu() {
|
394
|
-
|
395
|
-
let menu_temp = [
|
396
|
-
|
397
|
-
{
|
398
|
-
|
399
|
-
label: 'File',
|
400
|
-
|
401
|
-
submenu: [
|
402
|
-
|
403
|
-
{label: 'New', click: ()=>{
|
404
|
-
|
405
|
-
console.log('New menu.');
|
406
|
-
|
407
|
-
createWindow();
|
408
|
-
|
409
|
-
}},
|
410
|
-
|
411
|
-
{label: 'File', click: ()=>{
|
412
|
-
|
413
|
-
console.log('File menu.');
|
414
|
-
|
415
|
-
createWindow();
|
416
|
-
|
417
|
-
}},
|
418
|
-
|
419
|
-
{role: 'close'},
|
420
|
-
|
421
|
-
{type: 'separator'},
|
422
|
-
|
423
|
-
{role: 'quit'}
|
424
|
-
|
425
|
-
]
|
426
|
-
|
427
|
-
},
|
428
|
-
|
429
|
-
{role: 'editMenu'},
|
430
|
-
|
431
|
-
{role: 'viewMenu'},
|
432
|
-
|
433
|
-
{role:'windowMenu'},
|
434
|
-
|
435
|
-
{label: 'Help', submenu: [
|
436
|
-
|
437
|
-
{role: 'about'},
|
438
|
-
|
439
|
-
{type: 'separator'},
|
440
|
-
|
441
|
-
{role: 'reload'},
|
442
|
-
|
443
|
-
{role: 'zoomIn'},
|
444
|
-
|
445
|
-
{role: 'zoomOut'}
|
446
|
-
|
447
|
-
]}
|
448
|
-
|
449
|
-
];
|
450
|
-
|
451
|
-
let menu = Menu.buildFromTemplate(menu_temp);
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
Menu.setApplicationMenu(menu);
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
createMenu();
|
464
|
-
|
465
|
-
app.whenReady().then(createWindow);
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
```
|
470
|
-
|
471
|
-
```javascript
|
472
|
-
|
473
|
-
preload.js
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
const { remote } = require('electron');
|
478
|
-
|
479
|
-
const { dialog } = remote;
|
480
|
-
|
481
|
-
const { ipcRenderer } = require('electron');
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
window.remote = remote;
|
488
|
-
|
489
|
-
window.dialog = dialog;
|
490
|
-
|
491
|
-
window.ipcRenderer = ipcRenderer;
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
```
|
496
|
-
|
497
453
|
|
498
454
|
|
499
455
|
|
500
456
|
|
501
457
|
起動はMonaca Localkitのプレビュー表示で起動しており、正確なエラーメッセージは下記になります。
|
502
458
|
|
503
|
-
Uncaught
|
459
|
+
Uncaught ReferenceError: require is not defined
|
504
|
-
|
460
|
+
|
505
|
-
at index.html:2
|
461
|
+
at index.html:27
|
506
462
|
|
507
463
|
|
508
464
|
|
509
465
|
また、このままの状態でボタンを押すと、下記エラーも追加されます。
|
510
466
|
|
511
|
-
Uncaught ReferenceError: re
|
467
|
+
Uncaught ReferenceError: BrowserWindow is not defined
|
512
|
-
|
468
|
+
|
513
|
-
at doit (index.html:3
|
469
|
+
at doit (index.html:32)
|
514
470
|
|
515
471
|
at HTMLButtonElement.onclick (index.html:22)
|
516
472
|
|
2
ソースコード及び説明の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,6 +40,10 @@
|
|
40
40
|
|
41
41
|
</head>
|
42
42
|
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
43
47
|
<body>
|
44
48
|
|
45
49
|
<nav class="navbar bg-primary mb-4">
|
@@ -60,44 +64,36 @@
|
|
60
64
|
|
61
65
|
</div>
|
62
66
|
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
63
71
|
<script>
|
64
72
|
|
65
|
-
const { remote } = require('electron');
|
66
|
-
|
67
|
-
const
|
73
|
+
const BrowserWindow = window.remote.BrowserWindow;
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
|
73
|
-
function doit() {
|
75
|
+
function doit() {
|
74
|
-
|
76
|
+
|
75
|
-
let w
|
77
|
+
let w = remote.getCurrentWindow();
|
76
|
-
|
77
|
-
|
78
|
+
|
78
|
-
|
79
|
-
height: 300,
|
80
|
-
|
81
|
-
|
79
|
+
let re = dialog.showMessageBox(w, {
|
82
|
-
|
83
|
-
|
80
|
+
|
84
|
-
|
85
|
-
|
81
|
+
title:'Message',
|
82
|
+
|
86
|
-
|
83
|
+
message:'これがメッセージボックスの表示です。',
|
84
|
+
|
85
|
+
detail: 'OKすると閉じます。'
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
console.log(re);
|
90
|
+
|
87
|
-
|
91
|
+
}
|
88
|
-
|
89
|
-
});
|
90
|
-
|
91
|
-
win.loadFile('index.html');
|
92
|
-
|
93
|
-
document.querySelector('#msg').textContent
|
94
|
-
|
95
|
-
= 'Create new window!';
|
96
|
-
|
97
|
-
}
|
98
92
|
|
99
93
|
</script>
|
100
94
|
|
95
|
+
|
96
|
+
|
101
97
|
</body>
|
102
98
|
|
103
99
|
</html>
|
@@ -112,6 +108,8 @@
|
|
112
108
|
|
113
109
|
index.js
|
114
110
|
|
111
|
+
|
112
|
+
|
115
113
|
const { app, Menu, BrowserWindow } = require('electron');
|
116
114
|
|
117
115
|
const path = require('path');
|
@@ -130,9 +128,9 @@
|
|
130
128
|
|
131
129
|
webPreferences: {
|
132
130
|
|
133
|
-
nodeIntegration: true,
|
134
|
-
|
135
|
-
enableRemoteModule: true
|
131
|
+
enableRemoteModule: true,
|
132
|
+
|
133
|
+
preload: path.join(app.getAppPath(), 'preload.js')
|
136
134
|
|
137
135
|
}
|
138
136
|
|
@@ -224,6 +222,36 @@
|
|
224
222
|
|
225
223
|
```
|
226
224
|
|
225
|
+
```javascript
|
226
|
+
|
227
|
+
preload.js
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
const { remote } = require('electron');
|
232
|
+
|
233
|
+
const { dialog } = remote;
|
234
|
+
|
235
|
+
const { ipcRenderer } = require('electron');
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
window.remote = remote;
|
242
|
+
|
243
|
+
window.dialog = dialog;
|
244
|
+
|
245
|
+
window.ipcRenderer = ipcRenderer;
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
227
255
|
・Monaca移行用プログラム(テンプレートは「最小限のテンプレート」を使用しております。)
|
228
256
|
|
229
257
|
```html
|
@@ -282,44 +310,36 @@
|
|
282
310
|
|
283
311
|
</div>
|
284
312
|
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
285
317
|
<script>
|
286
318
|
|
287
|
-
const { remote } = require('electron');
|
288
|
-
|
289
|
-
const
|
319
|
+
const BrowserWindow = window.remote.BrowserWindow;
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
320
|
+
|
295
|
-
function doit() {
|
321
|
+
function doit() {
|
296
|
-
|
322
|
+
|
297
|
-
let w
|
323
|
+
let w = remote.getCurrentWindow();
|
298
|
-
|
299
|
-
|
324
|
+
|
300
|
-
|
301
|
-
height: 300,
|
302
|
-
|
303
|
-
|
325
|
+
let re = dialog.showMessageBox(w, {
|
304
|
-
|
305
|
-
|
326
|
+
|
306
|
-
|
307
|
-
|
327
|
+
title:'Message',
|
328
|
+
|
308
|
-
|
329
|
+
message:'これがメッセージボックスの表示です。',
|
330
|
+
|
331
|
+
detail: 'OKすると閉じます。'
|
332
|
+
|
333
|
+
});
|
334
|
+
|
335
|
+
console.log(re);
|
336
|
+
|
309
|
-
|
337
|
+
}
|
310
|
-
|
311
|
-
});
|
312
|
-
|
313
|
-
win.loadFile('index.html');
|
314
|
-
|
315
|
-
document.querySelector('#msg').textContent
|
316
|
-
|
317
|
-
= 'Create new window!';
|
318
|
-
|
319
|
-
}
|
320
338
|
|
321
339
|
</script>
|
322
340
|
|
341
|
+
|
342
|
+
|
323
343
|
</body>
|
324
344
|
|
325
345
|
</html>
|
@@ -334,6 +354,8 @@
|
|
334
354
|
|
335
355
|
index.js
|
336
356
|
|
357
|
+
|
358
|
+
|
337
359
|
const { app, Menu, BrowserWindow } = require('electron');
|
338
360
|
|
339
361
|
const path = require('path');
|
@@ -352,9 +374,9 @@
|
|
352
374
|
|
353
375
|
webPreferences: {
|
354
376
|
|
355
|
-
nodeIntegration: true,
|
356
|
-
|
357
|
-
enableRemoteModule: true
|
377
|
+
enableRemoteModule: true,
|
378
|
+
|
379
|
+
preload: path.join(app.getAppPath(), 'preload.js')
|
358
380
|
|
359
381
|
}
|
360
382
|
|
@@ -446,52 +468,56 @@
|
|
446
468
|
|
447
469
|
```
|
448
470
|
|
471
|
+
```javascript
|
472
|
+
|
473
|
+
preload.js
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
const { remote } = require('electron');
|
478
|
+
|
479
|
+
const { dialog } = remote;
|
480
|
+
|
481
|
+
const { ipcRenderer } = require('electron');
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
window.remote = remote;
|
488
|
+
|
489
|
+
window.dialog = dialog;
|
490
|
+
|
491
|
+
window.ipcRenderer = ipcRenderer;
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
```
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
449
501
|
起動はMonaca Localkitのプレビュー表示で起動しており、正確なエラーメッセージは下記になります。
|
450
502
|
|
451
|
-
Uncaught
|
503
|
+
Uncaught TypeError: Cannot read property 'BrowserWindow' of undefined
|
452
|
-
|
504
|
+
|
453
|
-
at index.html:2
|
505
|
+
at index.html:29
|
506
|
+
|
507
|
+
|
508
|
+
|
454
|
-
|
509
|
+
また、このままの状態でボタンを押すと、下記エラーも追加されます。
|
510
|
+
|
455
|
-
|
511
|
+
Uncaught ReferenceError: remote is not defined
|
512
|
+
|
456
|
-
|
513
|
+
at doit (index.html:31)
|
514
|
+
|
515
|
+
at HTMLButtonElement.onclick (index.html:22)
|
516
|
+
|
517
|
+
|
518
|
+
|
457
|
-
気がついた点としては、MonacaのElectronのサンプルアプリケーション「Electron TODO App」「Electron 最小限のテンプレート」は、「 require('electron');」をしている箇所がないため、何か根本的に間違えているような気
|
519
|
+
気がついた点としては、MonacaのElectronのサンプルアプリケーション「Electron TODO App」「Electron 最小限のテンプレート」は、「 require('electron');」をしている箇所がないため、何か根本的に間違えているような気はしております。
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
520
|
+
|
462
|
-
|
463
|
-
```javascript
|
464
|
-
|
465
|
-
const { remote } = require('electron');
|
466
|
-
|
467
|
-
const { dialog } = remote;
|
468
|
-
|
469
|
-
window.remote = remote;
|
470
|
-
|
471
|
-
window.dialog = dialog;
|
472
|
-
|
473
|
-
function doit() {
|
474
|
-
|
475
|
-
let w = remote.getCurrentWindow();
|
476
|
-
|
477
|
-
let re = dialog.showMessageBox(w, {
|
478
|
-
|
479
|
-
title:'Message',
|
480
|
-
|
481
|
-
message:'これがメッセージボックスの表示です。',
|
482
|
-
|
483
|
-
|
521
|
+
何がおかしいのか、ご指摘いただけると助かります。
|
484
|
-
|
485
|
-
|
522
|
+
|
486
|
-
|
487
|
-
|
523
|
+
以上、よろしくお願いします。
|
488
|
-
|
489
|
-
}
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
```
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
もし、Monacaでdialogを表示させる方法として、「require('electron');」以外の方法があればご教授いただきたくよろしくお願いします。
|
1
dialog部ソースコードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -460,6 +460,8 @@
|
|
460
460
|
|
461
461
|
なお、最終的には前回(2/15)Electronでalert表示が出来ないため、代案としてdialog表示をさせたいと考えており、下記のように作成したいと考えております。
|
462
462
|
|
463
|
+
```javascript
|
464
|
+
|
463
465
|
const { remote } = require('electron');
|
464
466
|
|
465
467
|
const { dialog } = remote;
|
@@ -468,6 +470,28 @@
|
|
468
470
|
|
469
471
|
window.dialog = dialog;
|
470
472
|
|
473
|
+
function doit() {
|
474
|
+
|
475
|
+
let w = remote.getCurrentWindow();
|
476
|
+
|
477
|
+
let re = dialog.showMessageBox(w, {
|
478
|
+
|
479
|
+
title:'Message',
|
480
|
+
|
481
|
+
message:'これがメッセージボックスの表示です。',
|
482
|
+
|
483
|
+
detail: 'OKすると閉じます。'
|
484
|
+
|
485
|
+
});
|
486
|
+
|
487
|
+
console.log(re);
|
488
|
+
|
489
|
+
}
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
```
|
494
|
+
|
471
495
|
|
472
496
|
|
473
497
|
もし、Monacaでdialogを表示させる方法として、「require('electron');」以外の方法があればご教授いただきたくよろしくお願いします。
|