mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 16:37:06 +08:00
add pre-run-check handler
This commit is contained in:
@@ -13,7 +13,6 @@ import { ChildProcess } from 'child_process'
|
|||||||
import * as JSONStream from 'JSONStream'
|
import * as JSONStream from 'JSONStream'
|
||||||
import { checkCookieListFormat } from '../../../../common/utils/cookie'
|
import { checkCookieListFormat } from '../../../../common/utils/cookie'
|
||||||
import { getAnyAvailablePuppeteerExecutable } from '../../DOWNLOAD_DEPENDENCIES/utils/puppeteer-executable/index'
|
import { getAnyAvailablePuppeteerExecutable } from '../../DOWNLOAD_DEPENDENCIES/utils/puppeteer-executable/index'
|
||||||
import { AUTO_CHAT_ERROR_EXIT_CODE } from '../../../../common/enums/auto-start-chat'
|
|
||||||
import { mainWindow } from '../../../window/mainWindow'
|
import { mainWindow } from '../../../window/mainWindow'
|
||||||
import {
|
import {
|
||||||
getAutoStartChatRecord,
|
getAutoStartChatRecord,
|
||||||
@@ -21,8 +20,7 @@ import {
|
|||||||
getCompanyLibrary,
|
getCompanyLibrary,
|
||||||
getJobLibrary,
|
getJobLibrary,
|
||||||
getJobHistoryByEncryptId,
|
getJobHistoryByEncryptId,
|
||||||
getMarkAsNotSuitRecord,
|
getMarkAsNotSuitRecord
|
||||||
saveAndGetCurrentRunRecord,
|
|
||||||
} from '../utils/db/index'
|
} from '../utils/db/index'
|
||||||
import { PageReq } from '../../../../common/types/pagination'
|
import { PageReq } from '../../../../common/types/pagination'
|
||||||
import { pipeWriteRegardlessError } from '../../utils/pipe'
|
import { pipeWriteRegardlessError } from '../../utils/pipe'
|
||||||
@@ -54,6 +52,12 @@ import { daemonEE, sendToDaemon } from '../connect-to-daemon'
|
|||||||
import { runCommon } from '../../../features/run-common'
|
import { runCommon } from '../../../features/run-common'
|
||||||
import { loginWithCookieAssistant } from '../../../features/login-with-cookie-assistant'
|
import { loginWithCookieAssistant } from '../../../features/login-with-cookie-assistant'
|
||||||
import { configWithBrowserAssistant } from '../../../features/config-with-browser-assistant'
|
import { configWithBrowserAssistant } from '../../../features/config-with-browser-assistant'
|
||||||
|
import {
|
||||||
|
createFirstLaunchNoticeApproveFlag,
|
||||||
|
isFirstLaunchNoticeApproveFlagExist,
|
||||||
|
waitForUserApproveAgreement
|
||||||
|
} from '../../../features/first-launch-notice-window'
|
||||||
|
import { getLastUsedAndAvailableBrowser } from '../../DOWNLOAD_DEPENDENCIES/utils/browser-history'
|
||||||
|
|
||||||
export default function initIpc() {
|
export default function initIpc() {
|
||||||
ipcMain.handle('fetch-config-file-content', async () => {
|
ipcMain.handle('fetch-config-file-content', async () => {
|
||||||
@@ -192,7 +196,7 @@ export default function initIpc() {
|
|||||||
ipcMain.handle('run-geek-auto-start-chat-with-boss', async (ev) => {
|
ipcMain.handle('run-geek-auto-start-chat-with-boss', async (ev) => {
|
||||||
const mode = 'geekAutoStartWithBossMain'
|
const mode = 'geekAutoStartWithBossMain'
|
||||||
const { runRecordId } = await runCommon({ mode })
|
const { runRecordId } = await runCommon({ mode })
|
||||||
daemonEE.on('message', function handler (message) {
|
daemonEE.on('message', function handler(message) {
|
||||||
if (message.workerId !== mode) {
|
if (message.workerId !== mode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -206,7 +210,7 @@ export default function initIpc() {
|
|||||||
ipcMain.handle('run-read-no-reply-auto-reminder', async () => {
|
ipcMain.handle('run-read-no-reply-auto-reminder', async () => {
|
||||||
const mode = 'readNoReplyAutoReminderMain'
|
const mode = 'readNoReplyAutoReminderMain'
|
||||||
const { runRecordId } = await runCommon({ mode })
|
const { runRecordId } = await runCommon({ mode })
|
||||||
daemonEE.on('message', function handler (message) {
|
daemonEE.on('message', function handler(message) {
|
||||||
if (message.workerId !== mode) {
|
if (message.workerId !== mode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -220,7 +224,7 @@ export default function initIpc() {
|
|||||||
ipcMain.handle('stop-geek-auto-start-chat-with-boss', async () => {
|
ipcMain.handle('stop-geek-auto-start-chat-with-boss', async () => {
|
||||||
mainWindow?.webContents.send('geek-auto-start-chat-with-boss-stopping')
|
mainWindow?.webContents.send('geek-auto-start-chat-with-boss-stopping')
|
||||||
const p = new Promise((resolve) => {
|
const p = new Promise((resolve) => {
|
||||||
daemonEE.on('message', function handler (message) {
|
daemonEE.on('message', function handler(message) {
|
||||||
if (message.workerId !== 'geekAutoStartWithBossMain') {
|
if (message.workerId !== 'geekAutoStartWithBossMain') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -233,7 +237,7 @@ export default function initIpc() {
|
|||||||
await sendToDaemon(
|
await sendToDaemon(
|
||||||
{
|
{
|
||||||
type: 'stop-worker',
|
type: 'stop-worker',
|
||||||
workerId: 'geekAutoStartWithBossMain',
|
workerId: 'geekAutoStartWithBossMain'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
needCallback: true
|
needCallback: true
|
||||||
@@ -246,8 +250,8 @@ export default function initIpc() {
|
|||||||
|
|
||||||
ipcMain.handle('stop-read-no-reply-auto-reminder', async () => {
|
ipcMain.handle('stop-read-no-reply-auto-reminder', async () => {
|
||||||
mainWindow?.webContents.send('read-no-reply-auto-reminder-stopping')
|
mainWindow?.webContents.send('read-no-reply-auto-reminder-stopping')
|
||||||
const p = new Promise(resolve => {
|
const p = new Promise((resolve) => {
|
||||||
daemonEE.on('message', function handler (message) {
|
daemonEE.on('message', function handler(message) {
|
||||||
if (message.workerId !== 'readNoReplyAutoReminderMain') {
|
if (message.workerId !== 'readNoReplyAutoReminderMain') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -260,7 +264,7 @@ export default function initIpc() {
|
|||||||
await sendToDaemon(
|
await sendToDaemon(
|
||||||
{
|
{
|
||||||
type: 'stop-worker',
|
type: 'stop-worker',
|
||||||
workerId: 'readNoReplyAutoReminderMain',
|
workerId: 'readNoReplyAutoReminderMain'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
needCallback: true
|
needCallback: true
|
||||||
@@ -536,6 +540,42 @@ export default function initIpc() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('pre-enter-setting-ui', async () => {
|
||||||
|
if (!isFirstLaunchNoticeApproveFlagExist()) {
|
||||||
|
try {
|
||||||
|
await waitForUserApproveAgreement({
|
||||||
|
windowOption: {
|
||||||
|
parent: mainWindow!,
|
||||||
|
modal: true,
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
createFirstLaunchNoticeApproveFlag()
|
||||||
|
} catch {
|
||||||
|
app.exit(0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const puppeteerExecutable = await getAnyAvailablePuppeteerExecutable()
|
||||||
|
if (!puppeteerExecutable) {
|
||||||
|
const lastBrowser = await getLastUsedAndAvailableBrowser()
|
||||||
|
if (!lastBrowser) {
|
||||||
|
try {
|
||||||
|
await configWithBrowserAssistant({
|
||||||
|
windowOption: {
|
||||||
|
parent: mainWindow!,
|
||||||
|
modal: true,
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
autoFind: true
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
void err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.handle('exit-app-immediately', () => {
|
ipcMain.handle('exit-app-immediately', () => {
|
||||||
app.exit(0)
|
app.exit(0)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import { app, BrowserWindow, shell } from 'electron'
|
import { BrowserWindow, shell } from 'electron'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { openDevTools } from '../commands'
|
import { openDevTools } from '../commands'
|
||||||
import {
|
|
||||||
createFirstLaunchNoticeApproveFlag,
|
|
||||||
isFirstLaunchNoticeApproveFlagExist,
|
|
||||||
waitForUserApproveAgreement
|
|
||||||
} from '../features/first-launch-notice-window'
|
|
||||||
import { daemonEE } from '../flow/OPEN_SETTING_WINDOW/connect-to-daemon'
|
import { daemonEE } from '../flow/OPEN_SETTING_WINDOW/connect-to-daemon'
|
||||||
import { getLastUsedAndAvailableBrowser } from '../flow/DOWNLOAD_DEPENDENCIES/utils/browser-history'
|
|
||||||
import { configWithBrowserAssistant } from '../features/config-with-browser-assistant'
|
|
||||||
export let mainWindow: BrowserWindow | null = null
|
export let mainWindow: BrowserWindow | null = null
|
||||||
|
|
||||||
export function createMainWindow(): BrowserWindow {
|
export function createMainWindow(): BrowserWindow {
|
||||||
@@ -33,36 +26,6 @@ export function createMainWindow(): BrowserWindow {
|
|||||||
mainWindow.on('ready-to-show', () => {
|
mainWindow.on('ready-to-show', () => {
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
})
|
})
|
||||||
mainWindow.on('ready-to-show', async () => {
|
|
||||||
if (!isFirstLaunchNoticeApproveFlagExist()) {
|
|
||||||
try {
|
|
||||||
await waitForUserApproveAgreement({
|
|
||||||
windowOption: {
|
|
||||||
parent: mainWindow!,
|
|
||||||
modal: true,
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
createFirstLaunchNoticeApproveFlag()
|
|
||||||
} catch {
|
|
||||||
app.exit(0)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const lastBrowser = await getLastUsedAndAvailableBrowser()
|
|
||||||
if (!lastBrowser) {
|
|
||||||
try {
|
|
||||||
await configWithBrowserAssistant({
|
|
||||||
windowOption: {
|
|
||||||
parent: mainWindow!,
|
|
||||||
modal: true,
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
autoFind: true
|
|
||||||
})
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
mainWindow.on('ready-to-show', async () => {
|
mainWindow.on('ready-to-show', async () => {
|
||||||
process.env.NODE_ENV === 'development' &&
|
process.env.NODE_ENV === 'development' &&
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -27,7 +27,14 @@ const router = useRouter()
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
gtagRenderer('bootstrap_mounted')
|
gtagRenderer('bootstrap_mounted')
|
||||||
await sleep(2000)
|
await sleep(1500)
|
||||||
router.replace('/main-layout')
|
try {
|
||||||
|
await electron.ipcRenderer.invoke('pre-enter-setting-ui')
|
||||||
|
} catch (err) {
|
||||||
|
console.log('pre-enter-setting-ui error', err)
|
||||||
|
} finally {
|
||||||
|
await sleep(500)
|
||||||
|
router.replace('/main-layout')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user