mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 06:27:09 +01:00
[enhancement]: Start minimized (#522)
* [enhancement]: support starting minimized * show window when dock clicked macos
This commit is contained in:
parent
77fa723cf8
commit
5caf0d439f
@ -568,6 +568,8 @@
|
||||
"skipDuration_description": "sets the duration to skip when using the skip buttons on the player bar",
|
||||
"skipPlaylistPage": "skip playlist page",
|
||||
"skipPlaylistPage_description": "when navigating to a playlist, go to the playlist song list page instead of the default page",
|
||||
"startMinimized": "start minimized",
|
||||
"startMinimized_description": "start the application in system tray",
|
||||
"theme": "theme",
|
||||
"theme_description": "sets the theme to use for the application",
|
||||
"themeDark": "theme (dark)",
|
||||
|
@ -206,7 +206,7 @@ const createTray = () => {
|
||||
tray.setContextMenu(contextMenu);
|
||||
};
|
||||
|
||||
const createWindow = async () => {
|
||||
const createWindow = async (first = true) => {
|
||||
if (isDevelopment) {
|
||||
await installExtensions();
|
||||
}
|
||||
@ -350,13 +350,14 @@ const createWindow = async () => {
|
||||
|
||||
mainWindow.loadURL(resolveHtmlPath('index.html'));
|
||||
|
||||
const startWindowMinimized = store.get('window_start_minimized', false) as boolean;
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
if (!mainWindow) {
|
||||
throw new Error('"mainWindow" is not defined');
|
||||
}
|
||||
if (process.env.START_MINIMIZED) {
|
||||
mainWindow.minimize();
|
||||
} else {
|
||||
|
||||
if (!first || !startWindowMinimized) {
|
||||
mainWindow.show();
|
||||
createWinThumbarButtons();
|
||||
}
|
||||
@ -608,7 +609,11 @@ if (!singleInstance) {
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (mainWindow === null) createWindow();
|
||||
if (mainWindow === null) createWindow(false);
|
||||
else if (!mainWindow.isVisible()) {
|
||||
mainWindow.show();
|
||||
createWinThumbarButtons();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(console.log);
|
||||
|
@ -131,6 +131,31 @@ export const WindowSettings = () => {
|
||||
isHidden: !isElectron(),
|
||||
title: t('setting.exitToTray', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
aria-label="Toggle start in tray"
|
||||
defaultChecked={settings.startMinimized}
|
||||
disabled={!isElectron()}
|
||||
onChange={(e) => {
|
||||
if (!e) return;
|
||||
localSettings?.set('window_start_minimized', e.currentTarget.checked);
|
||||
setSettings({
|
||||
window: {
|
||||
...settings,
|
||||
startMinimized: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
),
|
||||
description: t('setting.startMinimized', {
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
isHidden: !isElectron(),
|
||||
title: t('setting.startMinimized', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
];
|
||||
|
||||
return <SettingsSection options={windowOptions} />;
|
||||
|
@ -267,6 +267,7 @@ export interface SettingsState {
|
||||
disableAutoUpdate: boolean;
|
||||
exitToTray: boolean;
|
||||
minimizeToTray: boolean;
|
||||
startMinimized: boolean;
|
||||
windowBarStyle: Platform;
|
||||
};
|
||||
}
|
||||
@ -575,6 +576,7 @@ const initialState: SettingsState = {
|
||||
disableAutoUpdate: false,
|
||||
exitToTray: false,
|
||||
minimizeToTray: false,
|
||||
startMinimized: false,
|
||||
windowBarStyle: platformDefaultWindowBarStyle,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user