add logic to detect and handle login invalid - will exit auto start chat and show cookie assistant. add the logic to store cookie and local storage while auto start chat running.

This commit is contained in:
geekgeekrun
2024-03-03 23:28:36 +08:00
parent 6a7b402101
commit a25e7aedb9
7 changed files with 106 additions and 18 deletions
+7 -1
View File
@@ -19,6 +19,7 @@ import {
DOWNLOAD_ERROR_EXIT_CODE,
getAnyAvailablePuppeteerExecutable
} from '../flow/CHECK_AND_DOWNLOAD_DEPENDENCIES'
import { sleep } from '@geekgeekrun/utils/sleep.mjs'
let mainWindow: BrowserWindow | null = null
export function createMainWindow(): void {
@@ -123,13 +124,18 @@ export function createMainWindow(): void {
})
console.log(subProcessOfPuppeteer)
return new Promise((resolve, reject) => {
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => {
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', async (raw) => {
const data = raw
switch (data.type) {
case 'GEEK_AUTO_START_CHAT_WITH_BOSS_STARTED': {
resolve(data)
break
}
case 'LOGIN_STATUS_INVALID': {
await sleep(500)
mainWindow?.webContents.send('check-boss-zhipin-cookie-file')
return
}
default: {
return
}