Use built-in url parsing in preload script
Latest electron allows acces to the url module in a preload script. Also add a wrapper to shield global scope and use strict inside. // FREEBIE
This commit is contained in:
parent
878b15c288
commit
4d11e257fe
1 changed files with 8 additions and 12 deletions
20
preload.js
20
preload.js
|
@ -1,15 +1,11 @@
|
|||
/*
|
||||
* Pending electron 1.6.x
|
||||
* const env = require('url').parse(window.location, true).query;
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
console.log('preload');
|
||||
const electron = require('electron')
|
||||
|
||||
console.log('preload');
|
||||
window.config = require('url').parse(window.location.toString(), true).query;
|
||||
|
||||
window.config = {};
|
||||
window.location.search.substring(1).split('&').forEach(function(variable) {
|
||||
var pair = variable.split('=');
|
||||
config[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
||||
});
|
||||
const ipc = electron.ipcRenderer
|
||||
window.config.locale_json = ipc.sendSync('locale-data');
|
||||
|
||||
const ipc = require('electron').ipcRenderer
|
||||
window.config.locale_json = ipc.sendSync('locale-data');
|
||||
})();
|
||||
|
|
Loading…
Add table
Reference in a new issue