mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: Add scale ratio for tray icons (#1811)
This commit is contained in:
committed by
GitHub
parent
2205150b86
commit
5f090169da
11
src/tray.ts
11
src/tray.ts
@ -1,4 +1,4 @@
|
|||||||
import { Menu, nativeImage, Tray } from 'electron';
|
import { Menu, screen, nativeImage, Tray } from 'electron';
|
||||||
|
|
||||||
import defaultTrayIconAsset from '@assets/youtube-music-tray.png?asset&asarUnpack';
|
import defaultTrayIconAsset from '@assets/youtube-music-tray.png?asset&asarUnpack';
|
||||||
import pausedTrayIconAsset from '@assets/youtube-music-tray-paused.png?asset&asarUnpack';
|
import pausedTrayIconAsset from '@assets/youtube-music-tray-paused.png?asset&asarUnpack';
|
||||||
@ -48,13 +48,14 @@ export const setUpTray = (app: Electron.App, win: Electron.BrowserWindow) => {
|
|||||||
|
|
||||||
const { playPause, next, previous } = getSongControls(win);
|
const { playPause, next, previous } = getSongControls(win);
|
||||||
|
|
||||||
|
const pixelRatio = screen.getPrimaryDisplay().scaleFactor || 1;
|
||||||
const defaultTrayIcon = nativeImage.createFromPath(defaultTrayIconAsset).resize({
|
const defaultTrayIcon = nativeImage.createFromPath(defaultTrayIconAsset).resize({
|
||||||
width: 16,
|
width: 16 * pixelRatio,
|
||||||
height: 16,
|
height: 16 * pixelRatio,
|
||||||
});
|
});
|
||||||
const pausedTrayIcon = nativeImage.createFromPath(pausedTrayIconAsset).resize({
|
const pausedTrayIcon = nativeImage.createFromPath(pausedTrayIconAsset).resize({
|
||||||
width: 16,
|
width: 16 * pixelRatio,
|
||||||
height: 16,
|
height: 16 * pixelRatio,
|
||||||
});
|
});
|
||||||
|
|
||||||
tray = new Tray(defaultTrayIcon);
|
tray = new Tray(defaultTrayIcon);
|
||||||
|
|||||||
Reference in New Issue
Block a user