fix(electron): use dynamic load for exposed meta (#5251)

There is high possibilities of  circular dependencies when importing `exposed-meta` module. Change it to dynamic import to mitigate the issue..
This commit is contained in:
Peng Xiao
2023-12-13 05:17:17 +00:00
parent c9f900b69c
commit 31dc1f5e00
4 changed files with 56 additions and 41 deletions
@@ -5,7 +5,7 @@ import { type App, type BrowserWindow, ipcMain } from 'electron';
import { buildType, CLOUD_BASE_URL, isDev } from './config';
import { logger } from './logger';
import {
getOrCreateWindow,
getMainWindow,
handleOpenUrlInHiddenWindow,
mainWindowOrigin,
removeCookie,
@@ -39,8 +39,12 @@ export function setupDeepLink(app: App) {
// on windows & linux, we need to listen for the second-instance event
app.on('second-instance', (event, commandLine) => {
getOrCreateWindow()
getMainWindow()
.then(window => {
if (!window) {
logger.error('main window is not ready');
return;
}
window.show();
const url = commandLine.pop();
if (url?.startsWith(`${protocol}://`)) {
@@ -66,9 +70,9 @@ async function handleAffineUrl(url: string) {
}
async function handleOauthJwt(url: string) {
if (url) {
const mainWindow = await getMainWindow();
if (url && mainWindow) {
try {
const mainWindow = await getOrCreateWindow();
mainWindow.show();
const urlObj = new URL(url);
const token = urlObj.searchParams.get('token');