mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-02 02:43:33 +00:00
Add tray settings (#49)
This commit is contained in:
parent
eecbcddea3
commit
2b1c1d5e59
8 changed files with 198 additions and 28 deletions
|
|
@ -5,7 +5,7 @@ import {
|
|||
SettingsSection,
|
||||
SettingOption,
|
||||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { Select } from '/@/renderer/components';
|
||||
import { Select, Switch } from '/@/renderer/components';
|
||||
|
||||
const WINDOW_BAR_OPTIONS = [
|
||||
{ label: 'Web (hidden)', value: Platform.WEB },
|
||||
|
|
@ -13,6 +13,8 @@ const WINDOW_BAR_OPTIONS = [
|
|||
{ label: 'macOS', value: Platform.MACOS },
|
||||
];
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
export const WindowSettings = () => {
|
||||
const settings = useWindowSettings();
|
||||
const { setSettings } = useSettingsStoreActions();
|
||||
|
|
@ -39,6 +41,50 @@ export const WindowSettings = () => {
|
|||
isHidden: !isElectron(),
|
||||
title: 'Window bar style',
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
aria-label="Toggle minimize to tray"
|
||||
defaultChecked={settings.exitToTray}
|
||||
disabled={!isElectron()}
|
||||
onChange={(e) => {
|
||||
if (!e) return;
|
||||
localSettings?.set('window_minimize_to_tray', e.currentTarget.checked);
|
||||
setSettings({
|
||||
window: {
|
||||
...settings,
|
||||
minimizeToTray: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
),
|
||||
description: 'Minimize the application to the system tray',
|
||||
isHidden: !isElectron(),
|
||||
title: 'Minimize to tray',
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
aria-label="Toggle exit to tray"
|
||||
defaultChecked={settings.exitToTray}
|
||||
disabled={!isElectron()}
|
||||
onChange={(e) => {
|
||||
if (!e) return;
|
||||
localSettings?.set('window_exit_to_tray', e.currentTarget.checked);
|
||||
setSettings({
|
||||
window: {
|
||||
...settings,
|
||||
exitToTray: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
),
|
||||
description: 'Exit the application to the system tray',
|
||||
isHidden: !isElectron(),
|
||||
title: 'Exit to tray',
|
||||
},
|
||||
];
|
||||
|
||||
return <SettingsSection options={windowOptions} />;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue