This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
appcat
/
sonist
Archived
1
0
Fork 0

增加应用图标

2.x
宇天 2019-01-19 02:53:59 +08:00
parent 12a9065896
commit ad64f972c8
2 changed files with 36 additions and 1 deletions

BIN
images/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

37
main.js
View File

@ -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()