клонируем это:
https://electronjs.org/docs/tutorial...g-this-example
main.js
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
mainWindow.on('closed', function () {
mainWindow = null
})
mainWindow.webContents.openDevTools()
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
app.on('activate', function () {
if (mainWindow === null) createWindow()
})
ipcMain.on('change-page', (e, arg) => {
console.log('arg')
mainWindow.loadFile('index2.html')
})
preload.js
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const { ipcRenderer: ipc } = require('electron');
let Data = {
message: "Hi",
someData: "Let's go"
};
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
const el = document.querySelector('.change-page')
console.log('el', el)
el.addEventListener('click', e => {
console.log('click')
ipc.send('change-page', Data);
});
})
почитать по теме
https://electronjs.org/docs/api/ipc-main
https://electronjs.org/docs/api/ipc-renderer
https://ourcodeworld.com/articles/re...tron-framework
это конечно тупой способ...
лучше прикрутить hyperapp, react, vue, angular с BrowserRouter'ом...