feat(electron): more desktop app related shortcuts (#9724)

fix AF-2126, AF-2124

- Add CMD+M for minimize the app.
- Enhance how CMD+W works. Close the following in order, stop if any one is closed:
  - peek view
  - split view
  - tab
  - otherwise, hide the app
This commit is contained in:
pengx17
2025-01-16 06:50:08 +00:00
parent 676f855564
commit 9f3a304885
6 changed files with 56 additions and 8 deletions
@@ -42,4 +42,10 @@ export const uiEvents = {
sub.unsubscribe();
};
},
onCloseView: (fn: () => void) => {
const sub = uiSubjects.onCloseView$.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
} satisfies Record<string, MainEventRegister>;
@@ -71,6 +71,10 @@ export const uiHandlers = {
handleCloseApp: async () => {
app.quit();
},
handleHideApp: async () => {
const window = await getMainWindow();
window?.hide();
},
handleNetworkChange: async (_, _isOnline: boolean) => {
isOnline = _isOnline;
},
@@ -191,6 +195,7 @@ export const uiHandlers = {
closeTab: async (_, ...args: Parameters<typeof closeTab>) => {
await closeTab(...args);
},
activateView: async (_, ...args: Parameters<typeof activateView>) => {
await activateView(...args);
},
@@ -7,4 +7,6 @@ export const uiSubjects = {
onFullScreen$: new Subject<boolean>(),
onToggleRightSidebar$: new Subject<string>(),
authenticationRequest$: new Subject<AuthenticationRequest>(),
// via menu -> close view (CMD+W)
onCloseView$: new Subject<void>(),
};