mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
fix: image path
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
"!node_modules/**/*.map",
|
"!node_modules/**/*.map",
|
||||||
"!node_modules/**/*.ts"
|
"!node_modules/**/*.ts"
|
||||||
],
|
],
|
||||||
|
"asarUnpack": ["assets"],
|
||||||
"mac": {
|
"mac": {
|
||||||
"identity": null,
|
"identity": null,
|
||||||
"target": [
|
"target": [
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import { app, BrowserWindow, ipcMain, Notification } from 'electron';
|
import { app, BrowserWindow, ipcMain, Notification } from 'electron';
|
||||||
|
|
||||||
import { notificationImage, secondsToMinutes, ToastStyles } from './utils';
|
import { notificationImage, secondsToMinutes, ToastStyles } from './utils';
|
||||||
@ -9,7 +7,12 @@ import getSongControls from '../../providers/song-controls';
|
|||||||
import registerCallback, { SongInfo } from '../../providers/song-info';
|
import registerCallback, { SongInfo } from '../../providers/song-info';
|
||||||
import { changeProtocolHandler } from '../../providers/protocol-handler';
|
import { changeProtocolHandler } from '../../providers/protocol-handler';
|
||||||
import { setTrayOnClick, setTrayOnDoubleClick } from '../../tray';
|
import { setTrayOnClick, setTrayOnDoubleClick } from '../../tray';
|
||||||
import { getMediaIconLocation, mediaIcons, saveMediaIcon } from '../utils';
|
import { mediaIcons } from '../utils';
|
||||||
|
|
||||||
|
import playIcon from '../../../assets/media-icons-black/play.png?asset&asarUnpack';
|
||||||
|
import pauseIcon from '../../../assets/media-icons-black/pause.png?asset&asarUnpack';
|
||||||
|
import nextIcon from '../../../assets/media-icons-black/next.png?asset&asarUnpack';
|
||||||
|
import previousIcon from '../../../assets/media-icons-black/previous.png?asset&asarUnpack';
|
||||||
|
|
||||||
let songControls: ReturnType<typeof getSongControls>;
|
let songControls: ReturnType<typeof getSongControls>;
|
||||||
let savedNotification: Notification | undefined;
|
let savedNotification: Notification | undefined;
|
||||||
@ -22,10 +25,6 @@ export default (win: BrowserWindow) => {
|
|||||||
|
|
||||||
ipcMain.on('timeChanged', (_, t: number) => currentSeconds = t);
|
ipcMain.on('timeChanged', (_, t: number) => currentSeconds = t);
|
||||||
|
|
||||||
if (app.isPackaged) {
|
|
||||||
saveMediaIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
let savedSongInfo: SongInfo;
|
let savedSongInfo: SongInfo;
|
||||||
let lastUrl: string | undefined;
|
let lastUrl: string | undefined;
|
||||||
|
|
||||||
@ -152,6 +151,22 @@ const getXml = (songInfo: SongInfo, iconSrc: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectIcon = (kind: keyof typeof mediaIcons): string => {
|
||||||
|
switch (kind) {
|
||||||
|
case 'play':
|
||||||
|
return playIcon;
|
||||||
|
case 'pause':
|
||||||
|
return pauseIcon;
|
||||||
|
case 'next':
|
||||||
|
return nextIcon;
|
||||||
|
case 'previous':
|
||||||
|
return previousIcon;
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const display = (kind: keyof typeof mediaIcons) => {
|
const display = (kind: keyof typeof mediaIcons) => {
|
||||||
if (config.get('toastStyle') === ToastStyles.legacy) {
|
if (config.get('toastStyle') === ToastStyles.legacy) {
|
||||||
return `content="${mediaIcons[kind]}"`;
|
return `content="${mediaIcons[kind]}"`;
|
||||||
@ -159,7 +174,7 @@ const display = (kind: keyof typeof mediaIcons) => {
|
|||||||
|
|
||||||
return `\
|
return `\
|
||||||
content="${config.get('hideButtonText') ? '' : kind.charAt(0).toUpperCase() + kind.slice(1)}"\
|
content="${config.get('hideButtonText') ? '' : kind.charAt(0).toUpperCase() + kind.slice(1)}"\
|
||||||
imageUri="file:///${path.resolve(getMediaIconLocation(), `${kind}.png`)}"
|
imageUri="file:///${selectIcon(kind)}"
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import config from './config';
|
|||||||
import { cache } from '../../providers/decorators';
|
import { cache } from '../../providers/decorators';
|
||||||
import { SongInfo } from '../../providers/song-info';
|
import { SongInfo } from '../../providers/song-info';
|
||||||
|
|
||||||
import youtubeMusicIcon from '../../../assets/youtube-music.png?asset';
|
import youtubeMusicIcon from '../../../assets/youtube-music.png?asset&asarUnpack';
|
||||||
|
|
||||||
|
|
||||||
const userData = app.getPath('userData');
|
const userData = app.getPath('userData');
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
import path from 'node:path';
|
import { BrowserWindow, nativeImage } from 'electron';
|
||||||
|
|
||||||
import { app, BrowserWindow, nativeImage } from 'electron';
|
|
||||||
|
|
||||||
import getSongControls from '../../providers/song-controls';
|
import getSongControls from '../../providers/song-controls';
|
||||||
import registerCallback, { SongInfo } from '../../providers/song-info';
|
import registerCallback, { SongInfo } from '../../providers/song-info';
|
||||||
import { getMediaIconLocation, saveMediaIcon } from '../utils';
|
import { mediaIcons } from '../utils';
|
||||||
|
|
||||||
|
import playIcon from '../../../assets/media-icons-black/play.png?asset&asarUnpack';
|
||||||
|
import pauseIcon from '../../../assets/media-icons-black/pause.png?asset&asarUnpack';
|
||||||
|
import nextIcon from '../../../assets/media-icons-black/next.png?asset&asarUnpack';
|
||||||
|
import previousIcon from '../../../assets/media-icons-black/previous.png?asset&asarUnpack';
|
||||||
|
|
||||||
export default (win: BrowserWindow) => {
|
export default (win: BrowserWindow) => {
|
||||||
let currentSongInfo: SongInfo;
|
let currentSongInfo: SongInfo;
|
||||||
|
|
||||||
const { playPause, next, previous } = getSongControls(win);
|
const { playPause, next, previous } = getSongControls(win);
|
||||||
|
|
||||||
if (app.isPackaged) {
|
|
||||||
saveMediaIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
const setThumbar = (win: BrowserWindow, songInfo: SongInfo) => {
|
const setThumbar = (win: BrowserWindow, songInfo: SongInfo) => {
|
||||||
// Wait for song to start before setting thumbar
|
// Wait for song to start before setting thumbar
|
||||||
if (!songInfo?.title) {
|
if (!songInfo?.title) {
|
||||||
@ -47,8 +46,19 @@ export default (win: BrowserWindow) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Util
|
// Util
|
||||||
const get = (kind: string) => {
|
const get = (kind: keyof typeof mediaIcons): string => {
|
||||||
return path.join(getMediaIconLocation(), `${kind}.png`);
|
switch (kind) {
|
||||||
|
case 'play':
|
||||||
|
return playIcon;
|
||||||
|
case 'pause':
|
||||||
|
return pauseIcon;
|
||||||
|
case 'next':
|
||||||
|
return nextIcon;
|
||||||
|
case 'previous':
|
||||||
|
return previousIcon;
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
registerCallback((songInfo) => {
|
registerCallback((songInfo) => {
|
||||||
|
|||||||
@ -1,18 +1,9 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import { app } from 'electron';
|
|
||||||
import is from 'electron-is';
|
import is from 'electron-is';
|
||||||
|
|
||||||
import defaultConfig from '../config/defaults';
|
import defaultConfig from '../config/defaults';
|
||||||
|
|
||||||
export const getAssetsDirectoryLocation = () => path.resolve(__dirname, '..', 'assets');
|
|
||||||
|
|
||||||
export const getMediaIconLocation = () =>
|
|
||||||
app.isPackaged
|
|
||||||
? path.resolve(app.getPath('userData'), 'icons')
|
|
||||||
: path.resolve(getAssetsDirectoryLocation(), 'media-icons-black');
|
|
||||||
|
|
||||||
export const mediaIcons = {
|
export const mediaIcons = {
|
||||||
play: '\u{1405}', // ᐅ
|
play: '\u{1405}', // ᐅ
|
||||||
pause: '\u{2016}', // ‖
|
pause: '\u{2016}', // ‖
|
||||||
@ -20,19 +11,6 @@ export const mediaIcons = {
|
|||||||
previous: '\u{1438}', // ᐸ
|
previous: '\u{1438}', // ᐸ
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const saveMediaIcon = () => {
|
|
||||||
for (const kind of Object.keys(mediaIcons)) {
|
|
||||||
const destinationPath = path.join(getMediaIconLocation(), `${kind}.png`);
|
|
||||||
if (fs.existsSync(destinationPath)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const iconPath = path.resolve(path.resolve(getAssetsDirectoryLocation(), 'media-icons-black'), `${kind}.png`);
|
|
||||||
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
|
||||||
fs.copyFile(iconPath, destinationPath, () => {});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fileExists = (
|
export const fileExists = (
|
||||||
path: fs.PathLike,
|
path: fs.PathLike,
|
||||||
callbackIfExists: { (): void; (): void; (): void; },
|
callbackIfExists: { (): void; (): void; (): void; },
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import youtubeMusicTrayIcon from '../../assets/youtube-music-tray.png?asset';
|
import youtubeMusicTrayIcon from '../../assets/youtube-music-tray.png?asset&asarUnpack';
|
||||||
|
|
||||||
const promptOptions = {
|
const promptOptions = {
|
||||||
customStylesheet: 'dark',
|
customStylesheet: 'dark',
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { restart } from './providers/app-controls';
|
|||||||
import config from './config';
|
import config from './config';
|
||||||
import getSongControls from './providers/song-controls';
|
import getSongControls from './providers/song-controls';
|
||||||
|
|
||||||
import youtubeMusicTrayIcon from '../assets/youtube-music-tray.png?asset';
|
import youtubeMusicTrayIcon from '../assets/youtube-music-tray.png?asset&asarUnpack';
|
||||||
|
|
||||||
import type { MenuTemplate } from './menu';
|
import type { MenuTemplate } from './menu';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user