mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-17 05:02:06 +00:00
feat(menu): add theme list in menu
This commit is contained in:
@ -162,6 +162,14 @@
|
|||||||
"submenu": {
|
"submenu": {
|
||||||
"import-css-file": "Import custom CSS file",
|
"import-css-file": "Import custom CSS file",
|
||||||
"no-theme": "No theme"
|
"no-theme": "No theme"
|
||||||
|
},
|
||||||
|
"dialog": {
|
||||||
|
"remove-theme": "Are you sure you want to remove the custom theme?",
|
||||||
|
"remove-theme-message": "This will remove the custom theme",
|
||||||
|
"button": {
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"remove": "Remove"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
src/menu.ts
48
src/menu.ts
@ -1,13 +1,5 @@
|
|||||||
import is from 'electron-is';
|
import is from 'electron-is';
|
||||||
import {
|
import { app, BrowserWindow, clipboard, dialog, Menu, MenuItem, shell, } from 'electron';
|
||||||
app,
|
|
||||||
BrowserWindow,
|
|
||||||
clipboard,
|
|
||||||
dialog,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
shell,
|
|
||||||
} from 'electron';
|
|
||||||
import prompt from 'custom-electron-prompt';
|
import prompt from 'custom-electron-prompt';
|
||||||
import { satisfies } from 'semver';
|
import { satisfies } from 'semver';
|
||||||
|
|
||||||
@ -235,16 +227,41 @@ export const mainMenuTemplate = async (
|
|||||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.label',
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.label',
|
||||||
),
|
),
|
||||||
submenu: [
|
submenu: [
|
||||||
|
...((config.get('options.themes')?.length ?? 0) === 0
|
||||||
|
? [
|
||||||
{
|
{
|
||||||
label: t(
|
label: t(
|
||||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme',
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme',
|
||||||
),
|
),
|
||||||
type: 'radio',
|
}
|
||||||
checked: config.get('options.themes')?.length === 0, // Todo rename "themes"
|
]
|
||||||
click() {
|
: []),
|
||||||
config.set('options.themes', []);
|
...config.get('options.themes')?.map((theme: string) => ({
|
||||||
},
|
type: 'normal' as const,
|
||||||
},
|
label: theme,
|
||||||
|
async click() {
|
||||||
|
const { response } = await dialog.showMessageBox(win, {
|
||||||
|
type: 'question',
|
||||||
|
defaultId: 1,
|
||||||
|
title: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.dialog.remove-theme',
|
||||||
|
),
|
||||||
|
message: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.dialog.remove-theme-message',
|
||||||
|
{ theme },
|
||||||
|
),
|
||||||
|
buttons: [
|
||||||
|
t('main.menu.options.submenu.visual-tweaks.submenu.theme.dialog.button.cancel'),
|
||||||
|
t('main.menu.options.submenu.visual-tweaks.submenu.theme.dialog.button.remove'),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response === 1) {
|
||||||
|
config.set('options.themes', config.get('options.themes')?.filter((t) => t !== theme));
|
||||||
|
innerRefreshMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})),
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: t(
|
label: t(
|
||||||
@ -258,6 +275,7 @@ export const mainMenuTemplate = async (
|
|||||||
});
|
});
|
||||||
if (filePaths) {
|
if (filePaths) {
|
||||||
config.set('options.themes', filePaths);
|
config.set('options.themes', filePaths);
|
||||||
|
innerRefreshMenu();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user