diff --git a/packages/ui/electron.vite.config.ts b/packages/ui/electron.vite.config.ts index 5f4a137..5145cf8 100644 --- a/packages/ui/electron.vite.config.ts +++ b/packages/ui/electron.vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ }, plugins: [ externalizeDepsPlugin({ - exclude: ['@geekgeekrun/geek-auto-start-chat-with-boss', '@geekgeekrun/dingtalk-plugin', 'find-chrome-bin'] + exclude: ['@geekgeekrun/geek-auto-start-chat-with-boss', '@geekgeekrun/dingtalk-plugin', '@geekgeekrun/utils', 'find-chrome-bin'] }) ] }, diff --git a/packages/ui/package.json b/packages/ui/package.json index b37c1d2..d688793 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -26,6 +26,7 @@ "@electron-toolkit/utils": "^3.0.0", "@geekgeekrun/dingtalk-plugin": "workspace:*", "@geekgeekrun/geek-auto-start-chat-with-boss": "workspace:*", + "@geekgeekrun/utils": "workspace:*", "@puppeteer/browsers": "^2.0.0", "JSONStream": "^1.3.5", "electron-updater": "^6.1.7", diff --git a/packages/ui/src/main/flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index.ts b/packages/ui/src/main/flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index.ts index 2cedb8e..9f202bd 100644 --- a/packages/ui/src/main/flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index.ts +++ b/packages/ui/src/main/flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/index.ts @@ -11,6 +11,9 @@ import { saveLastUsedAndAvailableBrowserPath } from './history-utils' import findAndLocateExistedChromiumExecutable from './check-and-locate-existed-chromium-executable' +import { + sleep +} from '@geekgeekrun/utils/sleep.mjs' export enum DOWNLOAD_ERROR_EXIT_CODE { NO_ERROR = 0, @@ -118,6 +121,18 @@ export const checkAndDownloadDependenciesForInit = async () => { app.exit(DOWNLOAD_ERROR_EXIT_CODE.NO_ERROR) } catch (err) { console.error(err) + pipeWriteRegardlessError( + pipe, + JSON.stringify({ + type: 'PUPPETEER_DOWNLOAD_ENCOUNTER_ERROR', + ...err instanceof Error ? { + name: err.name, + message: err.message, + stack: err.stack + } : null + }) + '\r\n' + ) + await sleep(1000) app.exit(DOWNLOAD_ERROR_EXIT_CODE.DOWNLOAD_ERROR) } } diff --git a/packages/ui/src/main/window/mainWindow.ts b/packages/ui/src/main/window/mainWindow.ts index b51a1c8..4a3e4bc 100644 --- a/packages/ui/src/main/window/mainWindow.ts +++ b/packages/ui/src/main/window/mainWindow.ts @@ -165,6 +165,10 @@ export function createMainWindow(): void { mainWindow?.webContents.send(data.type, data) break } + case 'PUPPETEER_DOWNLOAD_ENCOUNTER_ERROR': { + console.error(data) + break; + } default: { return } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e372138..2b294ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,6 +57,9 @@ importers: '@geekgeekrun/geek-auto-start-chat-with-boss': specifier: workspace:* version: link:../geek-auto-start-chat-with-boss + '@geekgeekrun/utils': + specifier: workspace:* + version: link:../utils '@puppeteer/browsers': specifier: ^2.0.0 version: 2.0.0 @@ -1865,6 +1868,7 @@ packages: /@xmldom/xmldom@0.8.10: resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==} engines: {node: '>=10.0.0'} + requiresBuild: true dev: true /JSONStream@1.3.5: @@ -2063,6 +2067,7 @@ packages: /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + requiresBuild: true /basic-ftp@5.0.4: resolution: {integrity: sha512-8PzkB0arJFV4jJWSGOYR+OEic6aeKMu/osRhBULN6RY0ykby6LKhbmuQ5ublvaas5BOwboah5D87nrHyuh8PPA==} @@ -3448,6 +3453,7 @@ packages: /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + requiresBuild: true /ignore@5.3.1: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} @@ -5266,6 +5272,7 @@ packages: /xmlbuilder@15.1.1: resolution: {integrity: sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==} engines: {node: '>=8.0'} + requiresBuild: true dev: true /y18n@5.0.8: