mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-12 02:19:55 +08:00
add puppeteer download finish and error status
This commit is contained in:
@@ -15,17 +15,31 @@ export const checkAndDownloadDependenciesForInit = async () => {
|
||||
}) + '\r\n'
|
||||
)
|
||||
|
||||
const browser = await checkAndDownloadPuppeteer({
|
||||
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
||||
pipe?.write(
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
||||
totalBytes,
|
||||
downloadedBytes
|
||||
})
|
||||
) + '\r\n'
|
||||
}
|
||||
})
|
||||
let browser
|
||||
try {
|
||||
browser = await checkAndDownloadPuppeteer({
|
||||
downloadProgressCallback(downloadedBytes: number, totalBytes: number) {
|
||||
pipe?.write(
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_PROGRESS',
|
||||
totalBytes,
|
||||
downloadedBytes
|
||||
})
|
||||
) + '\r\n'
|
||||
}
|
||||
})
|
||||
pipe?.write(
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_FINISHED'
|
||||
})
|
||||
) + '\r\n'
|
||||
} catch (err) {
|
||||
pipe?.write(
|
||||
JSON.stringify({
|
||||
type: 'PUPPETEER_DOWNLOAD_ERROR'
|
||||
})
|
||||
) + '\r\n'
|
||||
}
|
||||
|
||||
console.log(browser)
|
||||
}
|
||||
|
||||
@@ -68,10 +68,9 @@ export const runAutoChat = async () => {
|
||||
(raw) => {
|
||||
const data = raw
|
||||
switch (data.type) {
|
||||
case 'NEED_RESETUP_DEPENDENCIES': {
|
||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
||||
break
|
||||
}
|
||||
case 'NEED_RESETUP_DEPENDENCIES':
|
||||
case 'PUPPETEER_DOWNLOAD_ERROR':
|
||||
case 'PUPPETEER_DOWNLOAD_FINISHED':
|
||||
case 'PUPPETEER_DOWNLOAD_PROGRESS': {
|
||||
pipe?.write(JSON.stringify(data) + '\r\n')
|
||||
break
|
||||
|
||||
@@ -112,12 +112,10 @@ export function createMainWindow(): void {
|
||||
resolve(data)
|
||||
break
|
||||
}
|
||||
case 'NEED_RESETUP_DEPENDENCIES': {
|
||||
mainWindow.webContents.send('NEED_RESETUP_DEPENDENCIES', data)
|
||||
break
|
||||
}
|
||||
case 'NEED_RESETUP_DEPENDENCIES':
|
||||
case 'PUPPETEER_DOWNLOAD_FINISHED':
|
||||
case 'PUPPETEER_DOWNLOAD_PROGRESS': {
|
||||
mainWindow.webContents.send('PUPPETEER_DOWNLOAD_PROGRESS', data)
|
||||
mainWindow.webContents.send(data.type, data)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -13,6 +13,6 @@ const handleProgress = (ev, { downloadedBytes, totalBytes }) => {
|
||||
}
|
||||
electron.ipcRenderer.on('PUPPETEER_DOWNLOAD_PROGRESS', handleProgress)
|
||||
onUnmounted(
|
||||
() => electron.ipcRenderer.off('PUPPETEER_DOWNLOAD_PROGRESS', handleProgress)
|
||||
() => electron.ipcRenderer.removeListener('PUPPETEER_DOWNLOAD_PROGRESS', handleProgress)
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -122,10 +122,15 @@ const shouldShowDependenciesWarmingUpDialog = ref(false)
|
||||
|
||||
const needWarmingUpDenpendenciesHandler = () => {
|
||||
shouldShowDependenciesWarmingUpDialog.value = true
|
||||
|
||||
const handlePuppeteerDownloadFinished = () => {
|
||||
shouldShowDependenciesWarmingUpDialog.value = false
|
||||
}
|
||||
electron.ipcRenderer.once('PUPPETEER_DOWNLOAD_FINISHED', handlePuppeteerDownloadFinished)
|
||||
}
|
||||
electron.ipcRenderer.on('NEED_CONFIGURATE_DEPENDENCIES', needWarmingUpDenpendenciesHandler)
|
||||
electron.ipcRenderer.on('NEED_RESETUP_DEPENDENCIES', needWarmingUpDenpendenciesHandler)
|
||||
onUnmounted(
|
||||
() => electron.ipcRenderer.off('NEED_RESETUP_DEPENDENCIES', needWarmingUpDenpendenciesHandler)
|
||||
() => electron.ipcRenderer.removeListener('NEED_RESETUP_DEPENDENCIES', needWarmingUpDenpendenciesHandler)
|
||||
)
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user