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

更新图标, 更新tray

master
宇天 2020-11-27 17:48:30 +08:00
parent 09b6b4c93c
commit 991661d03c
38 changed files with 90 additions and 45 deletions

Binary file not shown.

BIN
icons/tray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
icons/tray.psd Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/images/trays/tray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -54,6 +54,10 @@ Anot({
var list = app.dispatch('get-all-songs')
// var list = app.dispatch('scan-dir', { dir: '/Volumes/ooc/music' })
app.on('tray-play', ev => {
console.log('tray-play:', ev)
})
kb.on(['left'], ev => {
var time = this.song.time - 5
if (time < 0) {

View File

@ -5,9 +5,22 @@
*/
const { ipcRenderer } = require('electron')
const EventEmitter = require('events')
const util = require('util')
class Socket {
constructor() {
ipcRenderer.on('app', (ev, conn) => {
// console.log(ev, conn)
this.emit(conn.type, conn.data)
})
}
export default {
dispatch(type = '', data = {}) {
return ipcRenderer.sendSync('app', { data, type })
}
}
util.inherits(Socket, EventEmitter)
export default new Socket()

View File

@ -11,8 +11,6 @@ const fs = require('iofs')
require('./tools/init.js')
const { createMainWindow, createMiniWindow } = require('./tools/windows.js')
const { createAppTray, createLrcTray } = require('./tools/tray.js')
const createMenu = require('./tools/menu.js')
const MIME_TYPES = {
'.js': 'text/javascript',
@ -66,10 +64,6 @@ app.once('ready', () => {
let win = createMainWindow(path.resolve(__dirname, './images/app.png'))
createAppTray(win)
createLrcTray(win)
createMenu(win)
// mac专属事件,点击dock栏图标,可激活窗口
app.on('activate', _ => {
if (win) {

View File

@ -1,49 +1,74 @@
/**
* 托盘
* @author yutent<yutent@doui.cc>
* @date 2019/01/21 20:42:07
* 顶栏图标
* @author yutent<yutent.io@gmail.com>
* @date 2020/11/27 13:59:24
*/
'use strict'
const { ipcMain, Tray, Menu, nativeImage } = require('electron')
const path = require('path')
const { ipcMain, Tray, Menu, nativeImage } = require('electron')
function ctrlTrayBtn() {
var prev = new Tray(path.join(__dirname, '../images/ctrl/prev.png'))
var next = new Tray(path.join(__dirname, '../images/ctrl/next.png'))
var playIcon = [
path.join(__dirname, '../images/trays/playTemplate.png'),
path.join(__dirname, '../images/trays/pauseTemplate.png')
]
function create(ico) {
var tray = new Tray(ico)
tray.setIgnoreDoubleClickEvents(true)
return tray
}
exports.ctrlTrayBtn = function(win) {
var next = create(path.join(__dirname, '../images/trays/nextTemplate.png'))
var play = create(playIcon[1])
var prev = create(path.join(__dirname, '../images/trays/prevTemplate.png'))
var isPlaying = false
play.on('click', _ => {
isPlaying = !isPlaying
if (isPlaying) {
play.setImage(playIcon[0])
} else {
play.setImage(playIcon[1])
}
win.webContents.send('app', { type: 'tray-play', data: { isPlaying } })
})
prev.on('click', _ => {
win.webContents.send('app', { type: 'tray-prev', data: { isPlaying } })
})
next.on('click', _ => {
win.webContents.send('app', { type: 'tray-next', data: { isPlaying } })
})
console.log('ready', prev, play, next)
return { prev, play, next }
}
exports.createAppTray = function(win) {
var tray = new Tray(path.join(__dirname, '../images/trays/trayTemplate.png'))
tray.setIgnoreDoubleClickEvents(true)
// let menuList = Menu.buildFromTemplate([
// {
// label: '显示主窗口',
// click() {
// win.webContents.send('dock-click')
// }
// },
// { type: 'separator' },
// { label: '退出', role: 'quit' }
// ])
// if (process.platform === 'darwin') {
// tray.on('click', _ => {
// win.webContents.send('dock-click')
// })
// tray.on('right-click', _ => {
// tray.popUpContextMenu(menuList)
// })
// } else {
// tray.setContextMenu(menuList)
// }
var tray = create(path.join(__dirname, '../images/trays/tray.png'))
var menuList = Menu.buildFromTemplate([
{
label: '退出 Sonist',
accelerator: 'Command+Q',
click(a, b, ev) {
win.destroy()
}
}
])
tray.on('click', _ => {
win.restore()
})
tray.on('right-click', _ => {
tray.popUpContextMenu(menuList)
})
return tray
}
exports.createLrcTray = function(win) {
var nullImage = nativeImage.createEmpty()
var topbarLrc = new Tray(nullImage)
topbarLrc.setTitle('这是顶栏歌词, blablablabla...')
topbarLrc.setIgnoreDoubleClickEvents(true)
var tray = create(nullImage)
tray.setTitle('这是顶栏歌词, blablablabla...')
// ctrlTrayBtn()
return tray
}

View File

@ -1,11 +1,14 @@
/**
* 各种窗口创建
* @author yutent<yutent@doui.cc>
* @date 2019/01/26 18:28:22
* @author yutent<yutent.io@gmail.com>
* @date 2020/11/27 13:59:55
*/
const { BrowserWindow } = require('electron')
const { createAppTray, createLrcTray, ctrlTrayBtn } = require('./tray.js')
const createMenu = require('./menu.js')
/**
* 应用主窗口
*/
@ -36,9 +39,15 @@ exports.createMainWindow = function(icon) {
win.loadURL('app://local/index.html')
createAppTray(win)
ctrlTrayBtn(win)
createLrcTray(win)
createMenu(win)
win.on('ready-to-show', _ => {
win.show()
// win.openDevTools()
win.openDevTools()
})
win.on('close', ev => {