diff options
author | Ondrej Zara <[email protected]> | 2019-05-09 14:39:20 +0200 |
---|---|---|
committer | Ondrej Zara <[email protected]> | 2019-05-09 14:39:20 +0200 |
commit | 262da8a02396541de22f4f6516ce488f3488eb39 (patch) | |
tree | 7dae6ef51141178b49c0249093adba395351b5ec /desktop/main.js | |
parent | d8d47a9144eddd1523835a7a69670865f920720e (diff) | |
download | Orca-262da8a02396541de22f4f6516ce488f3488eb39.tar.gz Orca-262da8a02396541de22f4f6516ce488f3488eb39.zip |
rewrote require() to import/export
Diffstat (limited to 'desktop/main.js')
-rw-r--r-- | desktop/main.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/desktop/main.js b/desktop/main.js index 230db11..0bff62a 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -1,11 +1,27 @@ const { app, BrowserWindow, webFrame, Menu } = require('electron') const path = require('path') +require("electron").protocol.registerSchemesAsPrivileged([ + { scheme: "js", privileges: { standard: true, secure: true } } +]); + +function protocolHandler(request, respond) { + try { + let pathname = request.url.replace(/^js:\/*/, "") + let filename = path.resolve(app.getAppPath(), pathname) + respond({ mimeType:"text/javascript", data:require("fs").readFileSync(filename) }) + } catch (e) { + console.error(e, request) + } +} + let isShown = true app.win = null app.on('ready', () => { + require("electron").protocol.registerBufferProtocol("js", protocolHandler) + app.win = new BrowserWindow({ width: 710, height: 470, |