ipcRenderer.send('openWindow') }) 主窗口页面 newWindow.html 打开新窗口
let openWindow = (url): Promise<Window> => { return new Promise((resolve, reject) => { let dialog = window.open(url); dialog.window.parent = window; let dialogId = require("crypto").randomUUID(); dialog.window["__dialogId"] = dialogId; let readyHandler = (e) => { let msg =...
经过测试,window.open打开的窗口想要具备Node.js能力,需要父窗口开启nodeIntegration关闭上下文隔离,同时window.open的feature中配置nodeIntegration和上下文隔离 如果父窗口不具备Node.js执行能力,但是window.open配置了Node.js支持,并且frameName设置为一个已经存在并且具备Node.js能力的窗口,此时window.open加载的内容是否具备...
var{ipcMain,BrowserWindow} =require('electron');varpath=require('path');varwin=null;//接收到广播ipcMain.on('openWindow',function(){//调用 BrowserWindow打开新窗口win=newBrowserWindow({ width:400, height:300,//frame:false,//fullscreen:true}) win.loadURL(path.join('file:',__dirname,'../...
Electron是一个使用 JavaScript、HTML 和 CSS 构建桌面应用程序的框架。 嵌入 Chromium (opens new window) 和 Node.js (opens new window) 到 二进制的 Electron 允许您保持一个 JavaScript 代码代码库并创建 在W...
on("new-window", (event, navigationUrl) => { // 通知操作系统在默认浏览器上打开URL event.preventDefault(); shell.openExternal(navigationUrl); }); }); Electron 2.0 版本开始,会在可执行文件名为 Electron 时会为开发者在控制台显示安全相关的警告和建议,开发人员也可以在process.env或window对象上...
mainWindow.webContents.openDevTools();四、Electron 模块介绍 模块介绍、remote 模块、通 过 打开新窗口 4.1 Electron 主进程和渲染进程中的模块 4.2 Electron remote 模块 模块提供了一种在渲染进程(网页)和主进程之间进行进程间通讯(IPC)的简便途径 Electron中, 与GUI相关的模块(如dialog,menu等)只存在于主...
const mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js') } }) // 加载index.html mainWindow.loadFile('index.html') // 打开开发工具 // mainWindow.webContents.openDevTools() } // 这段程序将会在 Electron 结束初始化 /...
import { app, BrowserWindow } from 'electron';app.on('open-file', (event, filePath) => {event.preventDefault();// 获取主窗口const mainWindow = BrowserWindow.getFocusedWindow();// 加载文件mainWindow.loadFile(filePath);}); 注意:无论选择哪种方法,都要确保在加载文件之前已经创建了窗口实例或确...
this.instance = new WindowsMain() } return this.instance } } 实现创建窗口方法 newWindow(options: CreateWindowOptions): BrowserWindow { //通过创建窗口模块名称判断是否已经存在,存在就获取焦点,并将数据通过ipc通知到该窗口 if (this.winModulesMap.has(options.module)) { ...