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
sonist/src/tools/tray.js

39 lines
827 B
JavaScript

/**
* 托盘
* @author yutent<yutent@doui.cc>
* @date 2019/01/21 20:42:07
*/
'use strict'
const { app, Tray, Menu } = require('electron')
const path = require('path')
const ROOT = __dirname
module.exports = function(win) {
app.__TRAY__ = new Tray(
path.resolve(__dirname, '../images/trays/trayTemplate.png')
)
let menuList = Menu.buildFromTemplate([
{
label: '显示主窗口',
click() {
win.webContents.send('dock-click')
}
},
{ type: 'separator' },
{ label: '退出', role: 'quit' }
])
if (process.platform === 'darwin') {
app.__TRAY__.on('click', _ => {
win.webContents.send('dock-click')
})
app.__TRAY__.on('right-click', _ => {
app.__TRAY__.popUpContextMenu(menuList)
})
} else {
app.__TRAY__.setContextMenu(menuList)
}
}
一个音乐播放器, 主打本地音乐播放。支持 自动歌词/自动封面/均衡器等常见功能。
JavaScript 60.1%
SCSS 19.2%
HTML 16.9%
CSS 3.8%