mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-09 01:17:06 +08:00
add check dependencies logic before automatic start
This commit is contained in:
@@ -101,13 +101,8 @@ export function createMainWindow(): void {
|
|||||||
env: subProcessEnv,
|
env: subProcessEnv,
|
||||||
stdio: [null, null, null, 'pipe']
|
stdio: [null, null, null, 'pipe']
|
||||||
})
|
})
|
||||||
subProcessOfPuppeteer.once('exit', () => {
|
|
||||||
mainWindow.webContents.send('geek-auto-start-chat-with-boss-stopped')
|
|
||||||
|
|
||||||
subProcessOfPuppeteer = null
|
|
||||||
})
|
|
||||||
console.log(subProcessOfPuppeteer)
|
console.log(subProcessOfPuppeteer)
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve, reject) => {
|
||||||
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => {
|
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => {
|
||||||
const data = raw
|
const data = raw
|
||||||
switch (data.type) {
|
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:
|
// TODO:
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,8 +33,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import JSON5 from 'json5'
|
import JSON5 from 'json5'
|
||||||
import { ElForm, ElMessage, ElMessageBox } from 'element-plus'
|
import { ElForm, ElMessage } from 'element-plus'
|
||||||
import router from '../../router/index'
|
import router from '../../router/index'
|
||||||
|
import { mountGlobalDialog as mountDependenciesSetupProgressIndicatorDialog } from '@renderer/features/DependenciesSetupProgressIndicatorDialog/operations'
|
||||||
|
|
||||||
const formContent = ref({
|
const formContent = ref({
|
||||||
bossZhipinCookies: '',
|
bossZhipinCookies: '',
|
||||||
@@ -78,6 +79,8 @@ const formRef = ref<InstanceType<typeof ElForm>>()
|
|||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
await formRef.value!.validate()
|
await formRef.value!.validate()
|
||||||
await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value))
|
await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value))
|
||||||
|
|
||||||
|
try {
|
||||||
const res = await electron.ipcRenderer.invoke(
|
const res = await electron.ipcRenderer.invoke(
|
||||||
'run-geek-auto-start-chat-with-boss',
|
'run-geek-auto-start-chat-with-boss',
|
||||||
JSON.stringify(formContent.value)
|
JSON.stringify(formContent.value)
|
||||||
@@ -86,6 +89,19 @@ const handleSubmit = async () => {
|
|||||||
if (res.type === 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED') {
|
if (res.type === 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED') {
|
||||||
router.replace('/geekAutoStartChatWithBoss/runningStatus')
|
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 () => {
|
const handleSave = async () => {
|
||||||
await formRef.value!.validate()
|
await formRef.value!.validate()
|
||||||
|
|||||||
Reference in New Issue
Block a user