在须要做一些桌面特效:如雪花飘落成果的时候,须要窗体放弃通明且在所有窗口顶层
窗体根本代码如下
const path = require("path");const { app, BrowserWindow, Tray, Menu } = require("electron");function createWindow() { // 创立浏览器窗口 const win = new BrowserWindow({ fullscreen: true, transparent: true, // 窗口通明 frame: false, // 无边框 }); win.setIgnoreMouseEvents(true); // 鼠标穿透 win.setAlwaysOnTop(true); // 放弃置顶 win.setSkipTaskbar(true); // 无任务栏图标 win.loadFile("./app.html"); // 这里替换成有特效网页 //创立零碎告诉区菜单(右下角托盘) tray = new Tray(path.join(__dirname, "1.jpg")); const contextMenu = Menu.buildFromTemplate([ { label: "退出", click: () => { win.destroy(); }, }, //咱们须要在这里有一个真正的退出(这里间接强制退出) ]); tray.setToolTip("通明窗口托盘测试"); tray.setContextMenu(contextMenu);}app.whenReady().then(createWindow);
而后win.loadFile("./app.html")
替换成有特效的网页就OK了