mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-12 16:01:38 +08:00
add check dependencies logic before automatic start
This commit is contained in:
@@ -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:
|
||||
})
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import JSON5 from 'json5'
|
||||
import { ElForm, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElForm, ElMessage } from 'element-plus'
|
||||
import router from '../../router/index'
|
||||
import { mountGlobalDialog as mountDependenciesSetupProgressIndicatorDialog } from '@renderer/features/DependenciesSetupProgressIndicatorDialog/operations'
|
||||
|
||||
const formContent = ref({
|
||||
bossZhipinCookies: '',
|
||||
@@ -78,13 +79,28 @@ const formRef = ref<InstanceType<typeof ElForm>>()
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value!.validate()
|
||||
await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value))
|
||||
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')
|
||||
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: `Some dependencies might be corrupt. I'm trying to check and fix them.`
|
||||
})
|
||||
const checkDependenciesResult = await electron.ipcRenderer.invoke('check-dependencies')
|
||||
if (!checkDependenciesResult) {
|
||||
mountDependenciesSetupProgressIndicatorDialog()
|
||||
// TODO: should continue interrupted task
|
||||
}
|
||||
}
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
const handleSave = async () => {
|
||||
|
||||
Reference in New Issue
Block a user