From 20546c9fe669921256bfd9b88e7df02f7311aed9 Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sat, 9 Mar 2024 09:58:38 +0800 Subject: [PATCH] handle the scenario when user remove any chromium executable before click start job hunt --- packages/ui/src/main/window/mainWindow.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/ui/src/main/window/mainWindow.ts b/packages/ui/src/main/window/mainWindow.ts index c5a47b2..2b0934f 100644 --- a/packages/ui/src/main/window/mainWindow.ts +++ b/packages/ui/src/main/window/mainWindow.ts @@ -4,7 +4,6 @@ import * as childProcess from 'node:child_process' import { ensureConfigFileExist, ensureStorageFileExist, - configFileNameList, readConfigFile, writeConfigFile, @@ -28,8 +27,8 @@ export function createMainWindow(): void { autoHideMenuBar: true, ...(process.platform === 'linux' ? { - /* icon */ - } + /* icon */ + } : {}), webPreferences: { preload: path.join(__dirname, '../preload/index.js'), @@ -67,7 +66,7 @@ export function createMainWindow(): void { return readConfigFile(fileName) }) const result = { - config: {}, + config: {} } configFileNameList.forEach((fileName, index) => { @@ -109,11 +108,14 @@ export function createMainWindow(): void { if (subProcessOfPuppeteer) { return } - + const puppeteerExecutable = await getAnyAvailablePuppeteerExecutable() + if (!puppeteerExecutable) { + return Promise.reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES') + } const subProcessEnv = { ...process.env, MAIN_BOSSGEEKGO_UI_RUN_MODE: 'geekAutoStartWithBoss', - PUPPETEER_EXECUTABLE_PATH: (await getAnyAvailablePuppeteerExecutable())!.executablePath + PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath } subProcessOfPuppeteer = childProcess.spawn(process.argv[0], process.argv.slice(1), { env: subProcessEnv, @@ -168,7 +170,7 @@ export function createMainWindow(): void { } const subProcessEnv = { ...process.env, - MAIN_BOSSGEEKGO_UI_RUN_MODE: 'checkAndDownloadDependenciesForInit', + MAIN_BOSSGEEKGO_UI_RUN_MODE: 'checkAndDownloadDependenciesForInit' } subProcessOfCheckAndDownloadDependencies = childProcess.spawn( process.argv[0], @@ -191,7 +193,7 @@ export function createMainWindow(): void { } case 'PUPPETEER_DOWNLOAD_ENCOUNTER_ERROR': { console.error(data) - break; + break } default: { return