Здравствуйте, я новичок в Electron и пытаюсь записать событие из моего индекса. js в мой индекс. html, но я не могу заставить его работать.
Мой индекс. js код ниже
const electron = require('electron')
const { app, BrowserWindow, Menu, ipcMain, Tray, dialog, shell } = electron
app.on('ready', () => {
let win = new BrowserWindow({
minWidth: 750, minHeight: 250, width: 820, height: 550,
icon: __dirname + '/favicon.ico', maximizable: true, resizable: true,
webPreferences: {
nodeIntegration: false,
}
})
win.setMenu(null);
win.loadURL(`file://${__dirname}/index.html`)
var rows = { FirstName: 'John Doe' }
result.then(function(rows) {
win.webContents.send("resultSent", rows);
console.log(rows);
});
В то время как в моем индексе. html это
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Customer Management System</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<h1>Home</h1>
<div id="result"></div>
<script type="module">
const { ipcRenderer } = require("electron")
ipcRenderer.on("resultSent", function (event, data) {
console.log("received data", data)
alert("received data")
});
</script>
</body>
</html>
Но когда я открываю электрон, devTool возвращается ниже ошибки
Uncaught ReferenceError: require is not defined