javascript - Packaging app With Electron and Asar -
i have weird problem, i'm trying make website work offline (elearning course made adapt), i've created electron app wrapper:
main.js
creates browserwindow
loads index.html
function createwindow() { // create browser window. mainwindow = new browserwindow({ width: 800, height: 600, "min-width": 800, "min-height": 530, resize: true, "use-content-size": true }); // , load index.html of app. mainwindow.loadurl('file://' + __dirname + '/index.html'); // open devtools. mainwindow.webcontents.opendevtools(); // set window resizable mainwindow.isresizable(true); // emitted when window closed. mainwindow.on('closed', function () { // dereference window object, store windows // in array if app supports multi windows, time // when should delete corresponding element. mainwindow = null; }); }
the launcher of course (that hosts webview tag)
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <style> body { margin: 0; padding: 0; background-color: #6e6e6e; width: 100vw; height: 100vh; } webview { display: block; width: 100%; height: 100%; } </style> </head> <body> <webview src="build/scorm_test_harness.html" disablewebsecurity></webview> </body> </html>
and problem starts when i've turned off developer tools panel, once done course no longer loaded, when uncomment mainwindow.webcontents.opendevtools();
works again, @ moment i'm using workaround:
// open devtools. mainwindow.webcontents.opendevtools(); // close (almost) settimeout(function (webcontents) { webcontents.closedevtools(); }, 100, mainwindow.webcontents);
and works ugly patch, thoughts on anyone?
add non-empty <script>
tag somewhere in head
.
explanation:
if there no scripts on page, chrome
thinks page has no dynamic content on , doesn't creates scripting context, prohibits electron
core scripts injected page, , scripts responsible webview
tag handling (there issue reports bug on electron github repo, developers of electron stated, that intended behaviour (in chrome core), apparently, not bug, feature
xd).
here's related issue link.
Comments
Post a Comment