add the exit logic of read no reply auto reminder

This commit is contained in:
geekgeekrun
2024-11-03 16:43:22 +08:00
parent a7a83f6d68
commit 2aa8bb05bb
2 changed files with 14 additions and 2 deletions

View File

@@ -275,6 +275,13 @@ export default function initIpc() {
ipcMain.handle('stop-geek-auto-start-chat-with-boss', async () => {
mainWindow?.webContents.send('geek-auto-start-chat-with-boss-stopping')
subProcessOfPuppeteer?.kill()
setTimeout(() => {
try {
subProcessOfPuppeteer?.kill('SIGKILL')
} catch {
//
}
}, 1000)
})
let subProcessOfBossZhipinLoginPageWithPreloadExtension: ChildProcess | null = null

View File

@@ -27,7 +27,7 @@ export async function bootstrap() {
}
export async function launchBoss(browser: Browser) {
const page = await browser.newPage()
const page = (await browser.pages())[0]
//set cookies
for (let i = 0; i < bossCookies.length; i++) {
await page.setCookie(bossCookies[i])
@@ -35,6 +35,11 @@ export async function launchBoss(browser: Browser) {
await setDomainLocalStorage(browser, localStoragePageUrl, bossLocalStorage)
await Promise.all([page.goto(bossChatUiUrl, { timeout: 0 }), page.waitForNavigation()])
pageMapByName['boss'] = page
page.once('close', () => (pageMapByName['boss'] = null))
page.once('close', () => {
pageMapByName['boss'] = null
const cp = browser.process()
cp?.kill()
process.exit(0)
})
return page
}