mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-06 16:07:17 +08:00
remove useless ipc channel in GEEK_AUTO_START_CHAT_WITH_BOSS.ts - it only response for auto chat, not include download puppeteer
This commit is contained in:
@@ -5,10 +5,7 @@ import { readConfigFile } from '@bossgeekgo/geek-auto-start-chat-with-boss/runti
|
|||||||
import * as net from 'net'
|
import * as net from 'net'
|
||||||
import {
|
import {
|
||||||
checkPuppeteerExecutable,
|
checkPuppeteerExecutable,
|
||||||
getExpectPuppeteerExecutablePath
|
|
||||||
} from './CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer'
|
} from './CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer'
|
||||||
import * as childProcess from 'node:child_process'
|
|
||||||
import * as JSONStream from 'JSONStream'
|
|
||||||
|
|
||||||
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
||||||
|
|
||||||
@@ -36,67 +33,14 @@ export const runAutoChat = async () => {
|
|||||||
}) + '\r\n'
|
}) + '\r\n'
|
||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
console.error(new Error('PUPPETEER_MAY_NOT_INSTALLED'))
|
|
||||||
pipe?.write(
|
|
||||||
JSON.stringify({
|
|
||||||
type: 'PUPPETEER_MAY_NOT_INSTALLED'
|
|
||||||
}) + '\r\n'
|
|
||||||
)
|
|
||||||
app.exit(1)
|
app.exit(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const isPuppeteerExecutable = await checkPuppeteerExecutable()
|
const isPuppeteerExecutable = await checkPuppeteerExecutable()
|
||||||
if (!isPuppeteerExecutable) {
|
if (!isPuppeteerExecutable) {
|
||||||
const subProcessEnv = {
|
app.exit(1)
|
||||||
...process.env,
|
return
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'checkAndDownloadDependenciesForInit',
|
|
||||||
PUPPETEER_EXECUTABLE_PATH: await getExpectPuppeteerExecutablePath()
|
|
||||||
}
|
|
||||||
const subProcessOfCheckAndDownloadDependencies = childProcess.spawn(
|
|
||||||
process.argv[0],
|
|
||||||
process.argv.slice(1),
|
|
||||||
{
|
|
||||||
env: subProcessEnv,
|
|
||||||
stdio: [null, null, null, 'pipe']
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
|
||||||
subProcessOfCheckAndDownloadDependencies!.stdio[3]!.pipe(JSONStream.parse()).on(
|
|
||||||
'data',
|
|
||||||
(raw) => {
|
|
||||||
const data = raw
|
|
||||||
switch (data.type) {
|
|
||||||
case 'NEED_RESETUP_DEPENDENCIES':
|
|
||||||
case 'PUPPETEER_DOWNLOAD_PROGRESS': {
|
|
||||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'PUPPETEER_DOWNLOAD_FINISHED': {
|
|
||||||
subProcessOfCheckAndDownloadDependencies?.kill()
|
|
||||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
|
||||||
resolve(data)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'PUPPETEER_DOWNLOAD_ERROR': {
|
|
||||||
subProcessOfCheckAndDownloadDependencies?.kill()
|
|
||||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
|
||||||
resolve(data)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'PUPPETEER_MAY_NOT_INSTALLED': {
|
|
||||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
|
||||||
resolve(data)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mainLoop = (await import('@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs')).mainLoop
|
const mainLoop = (await import('@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs')).mainLoop
|
||||||
|
|||||||
@@ -111,17 +111,10 @@ export function createMainWindow(): void {
|
|||||||
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) {
|
||||||
case 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED':
|
case 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED': {
|
||||||
case 'PUPPETEER_MAY_NOT_INSTALLED': {
|
|
||||||
resolve(data)
|
resolve(data)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'NEED_RESETUP_DEPENDENCIES':
|
|
||||||
case 'PUPPETEER_DOWNLOAD_FINISHED':
|
|
||||||
case 'PUPPETEER_DOWNLOAD_PROGRESS': {
|
|
||||||
mainWindow.webContents.send(data.type, data)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,21 +85,6 @@ 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')
|
||||||
} else if (res.type === 'PUPPETEER_MAY_NOT_INSTALLED') {
|
|
||||||
ElMessageBox.confirm(
|
|
||||||
'Some core components is broken, please reinstall this program. Will you go to the download page?',
|
|
||||||
'Error',
|
|
||||||
{
|
|
||||||
confirmButtonText: 'OK',
|
|
||||||
cancelButtonText: 'Cancel',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
electron.ipcRenderer.emit('open-project-homepage-on-github')
|
|
||||||
})
|
|
||||||
.catch(() => {})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user