mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
fix: fix #30
This commit is contained in:
@ -9,6 +9,7 @@ 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 } from '../utils';
|
||||||
|
|
||||||
let songControls: ReturnType<typeof getSongControls>;
|
let songControls: ReturnType<typeof getSongControls>;
|
||||||
let savedNotification: Notification | undefined;
|
let savedNotification: Notification | undefined;
|
||||||
@ -151,11 +152,6 @@ const getXml = (songInfo: SongInfo, iconSrc: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const iconLocation = app.isPackaged
|
|
||||||
? path.resolve(app.getPath('userData'), 'icons')
|
|
||||||
: path.resolve(__dirname, 'assets', 'media-icons-black');
|
|
||||||
|
|
||||||
const display = (kind: keyof typeof icons) => {
|
const display = (kind: keyof typeof icons) => {
|
||||||
if (config.get('toastStyle') === ToastStyles.legacy) {
|
if (config.get('toastStyle') === ToastStyles.legacy) {
|
||||||
return `content="${icons[kind]}"`;
|
return `content="${icons[kind]}"`;
|
||||||
@ -163,7 +159,7 @@ const display = (kind: keyof typeof icons) => {
|
|||||||
|
|
||||||
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(__dirname, iconLocation, `${kind}.png`)}"
|
imageUri="file:///${path.resolve(getMediaIconLocation(), `${kind}.png`)}"
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,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 { getMediaIconLocation } from '../utils';
|
||||||
|
|
||||||
const icon = 'assets/youtube-music.png';
|
const icon = 'assets/youtube-music.png';
|
||||||
const userData = app.getPath('userData');
|
const userData = app.getPath('userData');
|
||||||
@ -88,10 +89,9 @@ export const saveTempIcon = () => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const iconPath = path.resolve(__dirname, 'assets', 'media-icons-black', `${kind}.png`);
|
const iconPath = path.resolve(getMediaIconLocation(), `${kind}.png`);
|
||||||
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
||||||
fs.copyFile(iconPath, destinationPath, () => {
|
fs.copyFile(iconPath, destinationPath, () => {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { 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 } from '../utils';
|
||||||
|
|
||||||
export default (win: BrowserWindow) => {
|
export default (win: BrowserWindow) => {
|
||||||
let currentSongInfo: SongInfo;
|
let currentSongInfo: SongInfo;
|
||||||
@ -43,7 +44,7 @@ export default (win: BrowserWindow) => {
|
|||||||
|
|
||||||
// Util
|
// Util
|
||||||
const get = (kind: string) => {
|
const get = (kind: string) => {
|
||||||
return path.join(__dirname, '../../assets/media-icons-black', `${kind}.png`);
|
return path.join(getMediaIconLocation(), `${kind}.png`);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerCallback((songInfo) => {
|
registerCallback((songInfo) => {
|
||||||
|
|||||||
@ -1,13 +1,18 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import { ipcMain, ipcRenderer } from 'electron';
|
import { app, ipcMain, ipcRenderer } from 'electron';
|
||||||
|
|
||||||
import is from 'electron-is';
|
import is from 'electron-is';
|
||||||
|
|
||||||
import { ValueOf } from '../utils/type-utils';
|
import { ValueOf } from '../utils/type-utils';
|
||||||
import defaultConfig from '../config/defaults';
|
import defaultConfig from '../config/defaults';
|
||||||
|
|
||||||
|
export const getMediaIconLocation = () =>
|
||||||
|
app.isPackaged
|
||||||
|
? path.resolve(app.getPath('userData'), 'icons')
|
||||||
|
: path.resolve(__dirname, 'assets', 'media-icons-black');
|
||||||
|
|
||||||
// Creates a DOM element from an HTML string
|
// Creates a DOM element from an HTML string
|
||||||
export const ElementFromHtml = (html: string): HTMLElement => {
|
export const ElementFromHtml = (html: string): HTMLElement => {
|
||||||
const template = document.createElement('template');
|
const template = document.createElement('template');
|
||||||
|
|||||||
Reference in New Issue
Block a user