mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
add the middle page (PrepareRun) between configuration page and RunningStatus page
This commit is contained in:
@@ -102,6 +102,14 @@ export function createMainWindow(): void {
|
|||||||
|
|
||||||
// const currentExecutablePath = app.getPath('exe')
|
// const currentExecutablePath = app.getPath('exe')
|
||||||
// console.log(currentExecutablePath)
|
// 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
|
let subProcessOfPuppeteer: ChildProcess | null = null
|
||||||
ipcMain.handle('run-geek-auto-start-chat-with-boss', async () => {
|
ipcMain.handle('run-geek-auto-start-chat-with-boss', async () => {
|
||||||
|
|||||||
@@ -50,28 +50,7 @@ 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 {
|
router.replace('/geekAutoStartChatWithBoss/prepareRun')
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
await formRef.value!.validate()
|
await formRef.value!.validate()
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<div class="geek-auto-start-chat-with-boss__prepare-run">
|
||||||
|
<div>{{ statusText }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { hasOwn } from '@vue/shared'
|
||||||
|
import { PropType, computed } from 'vue'
|
||||||
|
|
||||||
|
const statusTextMap = {
|
||||||
|
_: '请稍后,正在进行一些处理',
|
||||||
|
'locating-puppeteer-executable': '正在寻找可用的浏览器'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
status: {
|
||||||
|
type: String as PropType<keyof typeof statusText>,
|
||||||
|
default: '_'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const statusText = computed(() => {
|
||||||
|
if (hasOwn(statusTextMap, props.status)) {
|
||||||
|
return statusTextMap[props.status]
|
||||||
|
} else {
|
||||||
|
return statusTextMap._
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onUnmounted } from 'vue';
|
import { ref, onUnmounted, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import FlyingCompanyLogoList from '../../features/FlyingCompanyLogoList/index.vue'
|
import FlyingCompanyLogoList from '../../features/FlyingCompanyLogoList/index.vue'
|
||||||
|
|
||||||
@@ -40,6 +40,24 @@ onUnmounted(() => {
|
|||||||
ipcRenderer.removeListener('geek-auto-start-chat-with-boss-stopped', handleStopped)
|
ipcRenderer.removeListener('geek-auto-start-chat-with-boss-stopped', handleStopped)
|
||||||
ipcRenderer.removeListener('geek-auto-start-chat-with-boss-stopping', handleStopping)
|
ipcRenderer.removeListener('geek-auto-start-chat-with-boss-stopping', handleStopping)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
await electron.ipcRenderer.invoke('run-geek-auto-start-chat-with-boss')
|
||||||
|
} 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)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -1 +1,37 @@
|
|||||||
<template><RouterView /></template>
|
<template><RouterView :status="currentStatus" /></template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const currentStatus = ref('')
|
||||||
|
onMounted(() => {
|
||||||
|
const promise = electron.ipcRenderer.invoke('prepare-run-geek-auto-start-chat-with-boss')
|
||||||
|
const handleLocatingPuppeteerExecutable = () => {
|
||||||
|
currentStatus.value = 'locating-puppeteer-executable'
|
||||||
|
}
|
||||||
|
electron.ipcRenderer.once('locating-puppeteer-executable', handleLocatingPuppeteerExecutable)
|
||||||
|
onUnmounted(() => {
|
||||||
|
electron.ipcRenderer.removeListener(
|
||||||
|
'locating-puppeteer-executable',
|
||||||
|
handleLocatingPuppeteerExecutable
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
promise
|
||||||
|
.then(() => {
|
||||||
|
router.replace('/geekAutoStartChatWithBoss/runningStatus')
|
||||||
|
})
|
||||||
|
.then(async (err) => {
|
||||||
|
if (err instanceof Error && err.message.includes('NEED_TO_CHECK_RUNTIME_DEPENDENCIES')) {
|
||||||
|
ElMessage.error({
|
||||||
|
message: `核心组件损坏,正在尝试修复`
|
||||||
|
})
|
||||||
|
router.replace('/')
|
||||||
|
}
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { defineComponent, h } from 'vue'
|
|
||||||
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
||||||
import BootstrapSplash from '@renderer/page/BootstrapSplash/index.vue'
|
import BootstrapSplash from '@renderer/page/BootstrapSplash/index.vue'
|
||||||
|
|
||||||
const routes: Array<RouteRecordRaw> = [
|
const routes: Array<RouteRecordRaw> = [
|
||||||
{
|
{
|
||||||
path: '/cookieAssistant',
|
path: '/cookieAssistant',
|
||||||
component: () => import('@renderer/page/CookieAssistant/index.vue')
|
component: () => import('@renderer/page/CookieAssistant/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: 'Cookie 助手'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/configuration',
|
path: '/configuration',
|
||||||
@@ -25,6 +27,13 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
path: '/geekAutoStartChatWithBoss',
|
path: '/geekAutoStartChatWithBoss',
|
||||||
component: () => import('@renderer/page/GeekAutoStartChatWithBoss/index.vue'),
|
component: () => import('@renderer/page/GeekAutoStartChatWithBoss/index.vue'),
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
path: 'prepareRun',
|
||||||
|
component: () => import('@renderer/page/GeekAutoStartChatWithBoss/PrepareRun.vue'),
|
||||||
|
meta: {
|
||||||
|
title: 'BOSS炸弹 正在预热'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'runningStatus',
|
path: 'runningStatus',
|
||||||
component: () => import('@renderer/page/GeekAutoStartChatWithBoss/RunningStatus.vue'),
|
component: () => import('@renderer/page/GeekAutoStartChatWithBoss/RunningStatus.vue'),
|
||||||
@@ -37,14 +46,16 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
component: BootstrapSplash,
|
component: BootstrapSplash,
|
||||||
|
meta: {
|
||||||
|
title: '薪想事成'
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
// {
|
|
||||||
// path: '/',
|
|
||||||
// component: () => defineComponent({ setup: () => () => h('div') })
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
path: '/downloadingDependencies',
|
path: '/downloadingDependencies',
|
||||||
component: () => import('@renderer/page/BootstrapSplash/page/DownloadingDependencies.vue')
|
component: () => import('@renderer/page/BootstrapSplash/page/DownloadingDependencies.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '正在下载浏览器'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user