feat: Tray icon theme now follows system theme

This commit is contained in:
Revincx 2022-10-05 15:23:11 +08:00
parent 9fcb6da960
commit ce778afff6
No known key found for this signature in database
GPG Key ID: 6E79B88F79CA3126
3 changed files with 5 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,6 +1,6 @@
/* global __static */
import path from 'path';
import { app, nativeImage, Tray, Menu } from 'electron';
import { app, nativeImage, Tray, Menu, nativeTheme } from 'electron';
import { isLinux } from '@/utils/platform';
function createMenuTemplate(win) {
@ -197,8 +197,11 @@ class YPMTrayWindowsImpl {
}
export function createTray(win, eventEmitter) {
// 感觉图标颜色应该不属于界面主题范畴,只需要跟随系统主题
let iconTheme = nativeTheme.shouldUseDarkColors ? 'light' : 'dark';
let icon = nativeImage
.createFromPath(path.join(__static, 'img/icons/menu@88.png'))
.createFromPath(path.join(__static, `img/icons/menu-${iconTheme}@88.png`))
.resize({
height: 20,
width: 20,