diff --git a/icons/128x128.png b/icons/128x128.png new file mode 100644 index 0000000..0ac2ee1 Binary files /dev/null and b/icons/128x128.png differ diff --git a/icons/256x256.png b/icons/256x256.png new file mode 100644 index 0000000..b1b1646 Binary files /dev/null and b/icons/256x256.png differ diff --git a/icons/512x512.png b/icons/512x512.png new file mode 100644 index 0000000..62b3168 Binary files /dev/null and b/icons/512x512.png differ diff --git a/icons/app.png b/icons/app.png deleted file mode 100644 index 93452c1..0000000 Binary files a/icons/app.png and /dev/null differ diff --git a/package.json b/package.json index 5890a23..e286e9a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "productName": "Sonist", "copyright": "Copyright © 2019 ${author}", "directories": { + "buildResources": "icons", "output": "build" }, "files": ["src/**/*", "node_modules/iofs/*", "node_modules/crypto.js/*"], @@ -44,7 +45,7 @@ "arch": "x64" } ], - "icon": "icons/app.png" + "icon": "./icons/" }, "deb": { "depends": [ diff --git a/src/images/trays/trayTemplate@1.375x.png b/src/images/trays/trayTemplate@1.375x.png new file mode 100644 index 0000000..4eb939d Binary files /dev/null and b/src/images/trays/trayTemplate@1.375x.png differ diff --git a/src/images/trays/trayTemplate@1.5x.png b/src/images/trays/trayTemplate@1.5x.png new file mode 100644 index 0000000..b49e14c Binary files /dev/null and b/src/images/trays/trayTemplate@1.5x.png differ diff --git a/src/images/trays/trayTemplate@3x.png b/src/images/trays/trayTemplate@3x.png new file mode 100644 index 0000000..0116ce5 Binary files /dev/null and b/src/images/trays/trayTemplate@3x.png differ diff --git a/src/linux-stat.html b/src/linux-stat.html new file mode 100644 index 0000000..4223f42 --- /dev/null +++ b/src/linux-stat.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+ + +
+ + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 0b97475..3e7778d 100644 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,7 @@ const { protocol, Tray, Menu, + MenuItem, session } = require('electron') const path = require('path') @@ -25,7 +26,26 @@ const MIME_TYPES = { let win = null let tray = null -const template = [ +/* ----------------------------------------------------- */ + +const TRAYMENU_TMPL = [ + { + label: '显示Sonist', + type: 'normal', + click: () => { + win.show() + } + }, + { + type: 'separator' + }, + { + label: '退出应用', + type: 'normal', + role: 'quit' + } +] +const MENUBAR_TMPL = [ { label: 'View', submenu: [{ role: 'zoomin' }, { role: 'zoomout' }] @@ -37,17 +57,19 @@ const template = [ ] if (process.platform === 'darwin') { - template.unshift({ + MENU_TMPL.unshift({ label: 'Sonist', submenu: [{ role: 'about' }, { type: 'separator' }, { role: 'quit' }] }) // Window menu - template[2].submenu = [{ role: 'minimize' }] + MENUBAR_TMPL[2].submenu = [{ role: 'minimize' }] } -const menu = Menu.buildFromTemplate(template) -Menu.setApplicationMenu(menu) +let traymenuList = Menu.buildFromTemplate(TRAYMENU_TMPL) +let menubarList = Menu.buildFromTemplate(MENUBAR_TMPL) + +/* ----------------------------------------------------- */ function createWindow() { // 创建浏览器窗口 @@ -90,14 +112,19 @@ app.on('ready', () => { tray = new Tray(path.resolve(ROOT, './images/trays/trayTemplate.png')) - tray.on('click', _ => { - win.show() - }) + if (process.platform === 'darwin') { + tray.on('click', _ => { + win.show() + }) + } else { + tray.setContextMenu(traymenuList) + } + Menu.setApplicationMenu(menubarList) // const ses = session.defaultSession // ses.setUserAgent('Hello wolrd') createWindow() - win.tray = tray + // win.tray = tray win.webContents.openDevTools() })