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. // FREEBIEpull/749/head
parent
878b15c288
commit
4d11e257fe
@ -1,15 +1,11 @@
|
|||||||
/*
|
(function () {
|
||||||
* Pending electron 1.6.x
|
'use strict';
|
||||||
* const env = require('url').parse(window.location, true).query;
|
console.log('preload');
|
||||||
*/
|
const electron = require('electron')
|
||||||
|
|
||||||
console.log('preload');
|
window.config = require('url').parse(window.location.toString(), true).query;
|
||||||
|
|
||||||
window.config = {};
|
const ipc = electron.ipcRenderer
|
||||||
window.location.search.substring(1).split('&').forEach(function(variable) {
|
window.config.locale_json = ipc.sendSync('locale-data');
|
||||||
var pair = variable.split('=');
|
|
||||||
config[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
||||||
});
|
|
||||||
|
|
||||||
const ipc = require('electron').ipcRenderer
|
})();
|
||||||
window.config.locale_json = ipc.sendSync('locale-data');
|
|
||||||
|
Loading…
Reference in New Issue