mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-06 07:57:06 +08:00
add the ui for dedicate download progress of puppeteer; use JSONParse to parse the download progress; finish the logic to pass the progress to ui
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '@bossgeekgo/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import { ChildProcess } from 'child_process'
|
||||
import { getExpectPuppeteerExecutablePath } from '../flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer'
|
||||
import * as JSONStream from 'JSONStream'
|
||||
let mainWindow: BrowserWindow
|
||||
|
||||
export function createMainWindow(): void {
|
||||
@@ -103,14 +104,22 @@ export function createMainWindow(): void {
|
||||
})
|
||||
console.log(subProcessOfPuppeteer)
|
||||
return new Promise((resolve) => {
|
||||
subProcessOfPuppeteer!.stdio[3]!.on('data', (raw) => {
|
||||
const data = JSON.parse(raw.toString())
|
||||
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => {
|
||||
const data = raw
|
||||
switch (data.type) {
|
||||
case 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED':
|
||||
case 'PUPPETEER_MAY_NOT_INSTALLED': {
|
||||
resolve(data)
|
||||
break
|
||||
}
|
||||
case 'NEED_WARMING_UP_DEPENDENCIES': {
|
||||
mainWindow.webContents.send('NEED_WARMING_UP_DEPENDENCIES', data)
|
||||
break
|
||||
}
|
||||
case 'PUPPETEER_DOWNLOAD_PROGRESS': {
|
||||
mainWindow.webContents.send('PUPPETEER_DOWNLOAD_PROGRESS', data)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user