diff --git a/images/app.png b/images/app.png new file mode 100644 index 0000000..93452c1 Binary files /dev/null and b/images/app.png differ diff --git a/main.js b/main.js index 69f7f94..90e801d 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,11 @@ -const { app, BrowserWindow, protocol, Tray } = require('electron') +const { + app, + BrowserWindow, + protocol, + Tray, + Menu, + session +} = require('electron') const path = require('path') const fs = require('iofs') const log = console.log @@ -18,6 +25,30 @@ const MIME_TYPES = { let win = null let tray = null +const template = [ + { + label: 'View', + submenu: [{ role: 'zoomin' }, { role: 'zoomout' }] + }, + { + role: 'window', + submenu: [{ role: 'minimize' }, { role: 'close' }] + } +] + +if (process.platform === 'darwin') { + template.unshift({ + label: 'Sonist', + submenu: [{ role: 'about' }, { type: 'separator' }, { role: 'quit' }] + }) + + // Window menu + template[2].submenu = [{ role: 'minimize' }] +} + +const menu = Menu.buildFromTemplate(template) +Menu.setApplicationMenu(menu) + function createWindow() { // 创建浏览器窗口 win = new BrowserWindow({ @@ -26,6 +57,7 @@ function createWindow() { height: 640, frame: false, resizable: false, + icon: './images/app.png', webPreferences: { webSecurity: false, experimentalFeatures: true @@ -62,6 +94,9 @@ app.on('ready', () => { win.show() }) + // const ses = session.defaultSession + // ses.setUserAgent('Hello wolrd') + createWindow() win.tray = tray win.webContents.openDevTools()