From e794169020dcc53e45064222327f09fb8aa328bc Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sun, 10 Mar 2024 10:29:30 +0800 Subject: [PATCH] add the middle page (PrepareRun) between configuration page and RunningStatus page --- packages/ui/src/main/window/mainWindow.ts | 8 ++++ .../GeekAutoStartChatWithBoss.vue | 23 +---------- .../GeekAutoStartChatWithBoss/PrepareRun.vue | 29 ++++++++++++++ .../RunningStatus.vue | 20 +++++++++- .../page/GeekAutoStartChatWithBoss/index.vue | 38 ++++++++++++++++++- packages/ui/src/renderer/src/router/index.ts | 25 ++++++++---- 6 files changed, 112 insertions(+), 31 deletions(-) create mode 100644 packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/PrepareRun.vue diff --git a/packages/ui/src/main/window/mainWindow.ts b/packages/ui/src/main/window/mainWindow.ts index 2b0934f..03e5dae 100644 --- a/packages/ui/src/main/window/mainWindow.ts +++ b/packages/ui/src/main/window/mainWindow.ts @@ -102,6 +102,14 @@ export function createMainWindow(): void { // const currentExecutablePath = app.getPath('exe') // console.log(currentExecutablePath) + ipcMain.handle('prepare-run-geek-auto-start-chat-with-boss', async () => { + mainWindow?.webContents.send('locating-puppeteer-executable') + const puppeteerExecutable = await getAnyAvailablePuppeteerExecutable() + if (!puppeteerExecutable) { + return Promise.reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES') + } + mainWindow?.webContents.send('puppeteer-executable-is-located') + }) let subProcessOfPuppeteer: ChildProcess | null = null ipcMain.handle('run-geek-auto-start-chat-with-boss', async () => { diff --git a/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue b/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue index a0e794c..c42dd5e 100644 --- a/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue +++ b/packages/ui/src/renderer/src/page/Configuration/GeekAutoStartChatWithBoss.vue @@ -50,28 +50,7 @@ const handleSubmit = async () => { await formRef.value!.validate() await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value)) - try { - const res = await electron.ipcRenderer.invoke( - 'run-geek-auto-start-chat-with-boss', - JSON.stringify(formContent.value) - ) - - if (res.type === 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED') { - router.replace('/geekAutoStartChatWithBoss/runningStatus') - } - } catch (err) { - if (err instanceof Error && err.message.includes('NEED_TO_CHECK_RUNTIME_DEPENDENCIES')) { - ElMessage.error({ - message: `核心组件损坏,正在尝试修复` - }) - const checkDependenciesResult = await electron.ipcRenderer.invoke('check-dependencies') - if (Object.values(checkDependenciesResult).includes(false)) { - router.replace('/') - // TODO: should continue interrupted task - } - } - console.error(err) - } + router.replace('/geekAutoStartChatWithBoss/prepareRun') } const handleSave = async () => { await formRef.value!.validate() diff --git a/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/PrepareRun.vue b/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/PrepareRun.vue new file mode 100644 index 0000000..f03326c --- /dev/null +++ b/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/PrepareRun.vue @@ -0,0 +1,29 @@ + + + diff --git a/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/RunningStatus.vue b/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/RunningStatus.vue index ff16b52..27daff8 100644 --- a/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/RunningStatus.vue +++ b/packages/ui/src/renderer/src/page/GeekAutoStartChatWithBoss/RunningStatus.vue @@ -14,7 +14,7 @@