From 5ede58169d01f166eb36051847233ac9ab57da7f Mon Sep 17 00:00:00 2001 From: bossgeekgo Date: Sat, 17 Feb 2024 21:39:35 +0800 Subject: [PATCH] add check dependencies logic before automatic start --- packages/ui/src/main/window/mainWindow.ts | 17 +++++++---- .../GeekAutoStartChatWithBoss.vue | 30 ++++++++++++++----- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/packages/ui/src/main/window/mainWindow.ts b/packages/ui/src/main/window/mainWindow.ts index 094fc1e..35b02e4 100644 --- a/packages/ui/src/main/window/mainWindow.ts +++ b/packages/ui/src/main/window/mainWindow.ts @@ -101,13 +101,8 @@ export function createMainWindow(): void { env: subProcessEnv, stdio: [null, null, null, 'pipe'] }) - subProcessOfPuppeteer.once('exit', () => { - mainWindow.webContents.send('geek-auto-start-chat-with-boss-stopped') - - subProcessOfPuppeteer = null - }) console.log(subProcessOfPuppeteer) - return new Promise((resolve) => { + return new Promise((resolve, reject) => { subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => { const data = raw switch (data.type) { @@ -120,6 +115,16 @@ export function createMainWindow(): void { } } }) + + subProcessOfPuppeteer!.once('exit', (exitCode) => { + subProcessOfPuppeteer = null + if (exitCode === 1) { + // means cannot find downloaded puppeteer + reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES') + } else { + mainWindow.webContents.send('geek-auto-start-chat-with-boss-stopped') + } + }) }) // TODO: }) diff --git a/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue b/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue index 1930043..49eeca7 100644 --- a/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue +++ b/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue @@ -33,8 +33,9 @@