mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
feat(menu): add theme list in menu
This commit is contained in:
@ -162,6 +162,14 @@
|
||||
"submenu": {
|
||||
"import-css-file": "Import custom CSS file",
|
||||
"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 {
|
||||
app,
|
||||
BrowserWindow,
|
||||
clipboard,
|
||||
dialog,
|
||||
Menu,
|
||||
MenuItem,
|
||||
shell,
|
||||
} from 'electron';
|
||||
import { app, BrowserWindow, clipboard, dialog, Menu, MenuItem, shell, } from 'electron';
|
||||
import prompt from 'custom-electron-prompt';
|
||||
import { satisfies } from 'semver';
|
||||
|
||||
@ -235,16 +227,41 @@ export const mainMenuTemplate = async (
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.label',
|
||||
),
|
||||
submenu: [
|
||||
...((config.get('options.themes')?.length ?? 0) === 0
|
||||
? [
|
||||
{
|
||||
label: t(
|
||||
'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' },
|
||||
{
|
||||
label: t(
|
||||
@ -258,6 +275,7 @@ export const mainMenuTemplate = async (
|
||||
});
|
||||
if (filePaths) {
|
||||
config.set('options.themes', filePaths);
|
||||
innerRefreshMenu();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user