mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat: implement tray and minimize behaviors (#13851)
This PR introduces new window behaviors, which can be enabled when the menubar setting is active: New Features: - Quick open from tray icon - Minimize to tray - Exit to tray - Start minimized These changes have not yet been tested on macOS. <img width="645" height="479" alt="image" src="https://github.com/user-attachments/assets/7bdd13d0-5322-45a4-8e71-85c081aa0c86" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Configurable menubar/tray behaviors: open on left-click, minimize to tray, close to tray (exit to tray), and start minimized. * **UI** * Appearance settings add a Menubar → Window Behavior group with four toggles; group shows only when menubar/tray is enabled (hidden on macOS). * **Settings** * Tray settings persisted and exposed via the settings API with getters and setters for each option. * **Localization** * Added translation keys and English strings for the new controls and descriptions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
+84
-14
@@ -62,22 +62,92 @@ export const ThemeSettings = () => {
|
||||
const MenubarSetting = () => {
|
||||
const t = useI18n();
|
||||
const traySettingService = useService(TraySettingService);
|
||||
const { enabled } = useLiveData(traySettingService.setting$);
|
||||
const traySetting = useLiveData(traySettingService.settings$);
|
||||
|
||||
return (
|
||||
<SettingWrapper
|
||||
id="menubar"
|
||||
title={t['com.affine.appearanceSettings.menubar.title']()}
|
||||
>
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.menubar.toggle']()}
|
||||
desc={t['com.affine.appearanceSettings.menubar.description']()}
|
||||
<>
|
||||
<SettingWrapper
|
||||
id="menubar"
|
||||
title={t['com.affine.appearanceSettings.menubar.title']()}
|
||||
>
|
||||
<Switch
|
||||
checked={enabled}
|
||||
onChange={checked => traySettingService.setEnabled(checked)}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.menubar.toggle']()}
|
||||
desc={t['com.affine.appearanceSettings.menubar.description']()}
|
||||
>
|
||||
<Switch
|
||||
checked={traySetting.enabled}
|
||||
onChange={checked => traySettingService.setEnabled(checked)}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
{traySetting.enabled && !environment.isMacOs ? (
|
||||
<SettingWrapper
|
||||
id="windowBehavior"
|
||||
title={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.title'
|
||||
]()}
|
||||
>
|
||||
<SettingRow
|
||||
name={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.openOnLeftClick.toggle'
|
||||
]()}
|
||||
desc={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.openOnLeftClick.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
checked={traySetting.openOnLeftClick}
|
||||
onChange={checked =>
|
||||
traySettingService.setOpenOnLeftClick(checked)
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
name={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.minimizeToTray.toggle'
|
||||
]()}
|
||||
desc={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.minimizeToTray.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
checked={traySetting.minimizeToTray}
|
||||
onChange={checked =>
|
||||
traySettingService.setMinimizeToTray(checked)
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
name={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.closeToTray.toggle'
|
||||
]()}
|
||||
desc={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.closeToTray.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
checked={traySetting.closeToTray}
|
||||
onChange={checked => traySettingService.setCloseToTray(checked)}
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
name={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.startMinimized.toggle'
|
||||
]()}
|
||||
desc={t[
|
||||
'com.affine.appearanceSettings.menubar.windowBehavior.startMinimized.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
checked={traySetting.startMinimized}
|
||||
onChange={checked =>
|
||||
traySettingService.setStartMinimized(checked)
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user