'use strict'; const{app,Tray,BrowserWindow} = require('electron') const path = require('path') const url = require('url') let count = 0 let timer = null let tray = null let win function createWindow(){ win = new BrowserWindow({show:false,backgroundColor:"#006699",title:"万码学堂综合业务管理系统WMS1.0"}) win.setIcon('build/64.ico') win.maximize() win.show() win.loadURL(url.format({ pathname:path.join(__dirname,'index.html'), protocol:'file:', slashes:true })) //win.webContents.openDevTools() //窗口关闭时,只是隐藏了 win.on('close',(e)=>{ win.hide(); win.setSkipTaskbar(true); e.preventDefault() }) //托盘通知 tray = new Tray('build/64.ico'); //右键菜单 const contextMenu = Menu.buildFromTemplate([ { label: '退出', click: function(){ win.destroy() win = null app.quit(); } } ]); tray.setToolTip('万码学堂'); //点击显示窗口 tray.on('click',()=>{ if(win.isVisible()){ win.hide() win.setSkipTaskbar(false) } else{ win.maximize() win.show() win.setSkipTaskbar(true) } }); tray.setContextMenu(contextMenu); } app.on('ready',createWindow) app.on('window-all-closed',()=>{ if(process.platform!=='darwin'){ app.quit() } }) app.on('activate',()=>{ if(win===null){ createWindow() } })
0条评论
我要评论