diff --git a/src/main/index.js b/src/main/index.js index a3eebce..170cb48 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, protocol, ipcMain, dialog, nativeImage } = require('electron') +const { app, BrowserWindow, protocol, ipcMain, dialog, nativeImage, Menu, Tray } = require('electron') const path = require('path') const gotTheLock = app.requestSingleInstanceLock(); @@ -10,18 +10,22 @@ if (!gotTheLock) { } let mainWindow; +let tray = null; function createWindow() { // Create the browser window. mainWindow = new BrowserWindow({ - width: 1080, - height: 600, - minWidth: 400, + frame: false, + width: 1200, + height: 930, + minWidth: 1200, + minHeight: 930, webPreferences: { nodeIntegration: true, // javascript: true, // plugins: true, preload: path.join(__dirname, './', 'preload.js'), }, + icon: path.join(__dirname, 'logo.ico'), // frame: false, }) // and load the index.html of the app. @@ -34,8 +38,10 @@ function createWindow() { mainWindow.setMenuBarVisibility(false); // Open the DevTools. // mainWindow.webContents.openDevTools() - mainWindow.maximize(); + //mainWindow.maximize(); + // 返回应用默认的session对象 + // const ses = mainWindow.webContents.session; // 当窗口已经关闭的时候触发 mainWindow.on('closed', (event) => { mainWindow = null; @@ -47,16 +53,16 @@ function createWindow() { event.preventDefault(); }); - mainWindow.on('show', () => { - tray.setHighlightMode('always') - }) - mainWindow.on('hide', () => { - tray.setHighlightMode('never') - }) + // mainWindow.on('show', () => { + // tray.setHighlightMode('always') + // }) + // mainWindow.on('hide', () => { + // tray.setHighlightMode('never') + // }) // 创建系统通知区菜单 - tray = new Tray(path.join(__dirname, 'file_word.png')); - const contextMenu = Menu.buildFromTemplate([ + tray = new Tray(path.join(__dirname, 'logo.ico')); + const contextMenu = Menu.buildFromTemplate([ {label: '最大化', click: () => { mainWindow.maximize()}}, {label: '最小化', click: () => {mainWindow.minimize()}}, {label: '还原', click: () => {mainWindow.restore()}},