Electron一个使用HTML、CSS和JavaScript开发桌面应用程序的框架。Electron可以生成在Windows、macOS和Linux上运行的应用程序,借助Electron可以把我们的web端应用直接移植到桌面端而无需再次开发,这样我们可以使用同一套代码在不同平台上运行应用,极大的缩短了开发时间。
右键菜单,使用remote模块
const { app, BrowserWindow } = require("electron");
const remote=require('@electron/remote/main');
remote.initialize();
const path = require("path");
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences:{
nodeIntegration:true, //开启渲染进程中使用nodejs
contextIsolation:false, //开启渲染进程中使用nodejs
}
});
//启动remote模块
remote.enable(mainWindow.webContents)
//在