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