Я хочу передать переменные между двумя моими html-файлами в электронном виде, вот что я пробовал, но ничего не произошлоЯ что-то не так сделал?
main.js:
const {app , BrowserWindow} = require('electron');
const ipc = require('electron').ipcMain;
app.on('ready', function(){
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
mainWindow.on('closed',()=>{
mainWindow = null;
});
mainWindow.webContents.loadFile(__dirname + '/index.html');
});
ipc.on('set_token', function(event, arg){
mainWindow.webContents.send('tokens', arg);
});
firstfile.js:
const ipc = require('electron').ipcRenderer;
ipc.send('set_token', "someValue");
secondfile.js:
const ipc = require('electron').ipcRenderer;
const tes = document.getElementById("send");
const ipc = require('electron').ipcRenderer;
tes.addEventListener('click', function(event){
var hi = document.getElementById("hi");
ipc.on('tokens', function(event, arg){
hi.innerHTML = arg;
});
});
});