feat: add open app route (#3899)

This commit is contained in:
Peng Xiao
2023-08-30 06:40:25 +08:00
committed by GitHub
parent 71b195d9a9
commit 800f3c3cb6
29 changed files with 486 additions and 104 deletions
+9 -1
View File
@@ -5,10 +5,18 @@ import { uiSubjects } from './subject';
* Events triggered by application menu
*/
export const uiEvents = {
onFinishLogin: (fn: () => void) => {
onFinishLogin: (
fn: (result: { success: boolean; email: string }) => void
) => {
const sub = uiSubjects.onFinishLogin.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
onStartLogin: (fn: (opts: { email: string }) => void) => {
const sub = uiSubjects.onStartLogin.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
} satisfies Record<string, MainEventRegister>;
-6
View File
@@ -1,10 +1,8 @@
import { app, BrowserWindow, nativeTheme } from 'electron';
import { isMacOS } from '../../shared/utils';
import { closePopup } from '../main-window';
import type { NamespaceHandlers } from '../type';
import { getGoogleOauthCode } from './google-auth';
import { uiSubjects } from './subject';
export const uiHandlers = {
handleThemeChange: async (_, theme: (typeof nativeTheme)['themeSource']) => {
@@ -38,10 +36,6 @@ export const uiHandlers = {
handleCloseApp: async () => {
app.quit();
},
handleFinishLogin: async () => {
closePopup();
uiSubjects.onFinishLogin.next();
},
getGoogleOauthCode: async () => {
return getGoogleOauthCode();
},
+2 -1
View File
@@ -1,5 +1,6 @@
import { Subject } from 'rxjs';
export const uiSubjects = {
onFinishLogin: new Subject<void>(),
onStartLogin: new Subject<{ email: string }>(),
onFinishLogin: new Subject<{ success: boolean; email: string }>(),
};