mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 15:38:46 +08:00
fix cannot run in packaged app for auto reminder
This commit is contained in:
@@ -12,7 +12,7 @@ import { getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss
|
|||||||
import { AutoStartChatRunRecord } from '@geekgeekrun/sqlite-plugin/dist/entity/AutoStartChatRunRecord'
|
import { AutoStartChatRunRecord } from '@geekgeekrun/sqlite-plugin/dist/entity/AutoStartChatRunRecord'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||||
|
const isUiDev = process.env.NODE_ENV === 'development'
|
||||||
const rerunInterval = (() => {
|
const rerunInterval = (() => {
|
||||||
let v = Number(process.env.MAIN_BOSSGEEKGO_RERUN_INTERVAL)
|
let v = Number(process.env.MAIN_BOSSGEEKGO_RERUN_INTERVAL)
|
||||||
if (isNaN(v)) {
|
if (isNaN(v)) {
|
||||||
@@ -24,7 +24,9 @@ const rerunInterval = (() => {
|
|||||||
function runWithDaemon({ runRecordId, runMode, parentProcessPipe }) {
|
function runWithDaemon({ runRecordId, runMode, parentProcessPipe }) {
|
||||||
const subProcessOfCore = childProcess.spawn(
|
const subProcessOfCore = childProcess.spawn(
|
||||||
process.argv[0],
|
process.argv[0],
|
||||||
[...process.argv.slice(1), `--run-record-id=${runRecordId}`],
|
isUiDev
|
||||||
|
? [...process.argv.slice(1), `--run-record-id=${runRecordId}`]
|
||||||
|
: [`--run-record-id=${runRecordId}`],
|
||||||
{
|
{
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc'],
|
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc'],
|
||||||
env: {
|
env: {
|
||||||
@@ -73,7 +75,7 @@ function runWithDaemon({ runRecordId, runMode, parentProcessPipe }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function runAutoChatWithDaemon() {
|
export async function runAutoChatWithDaemon() {
|
||||||
const commandlineArgs = minimist(process.argv.slice(2))
|
const commandlineArgs = minimist(isUiDev ? process.argv.slice(2) : process.argv.slice(1))
|
||||||
if (!['geekAutoStartWithBossMain'].includes(commandlineArgs['mode-to-daemon'])) {
|
if (!['geekAutoStartWithBossMain'].includes(commandlineArgs['mode-to-daemon'])) {
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
app.once('ready', () => resolve(undefined))
|
app.once('ready', () => resolve(undefined))
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { Browser } from 'puppeteer'
|
import { Browser } from 'puppeteer'
|
||||||
import puppeteer from 'puppeteer-extra'
|
import { initPuppeteer } from '@geekgeekrun/geek-auto-start-chat-with-boss/index.mjs'
|
||||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
|
||||||
import { pageMapByName } from './index'
|
import { pageMapByName } from './index'
|
||||||
|
|
||||||
import { readStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
import { readStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||||
import { setDomainLocalStorage } from '@geekgeekrun/utils/puppeteer/local-storage.mjs'
|
import { setDomainLocalStorage } from '@geekgeekrun/utils/puppeteer/local-storage.mjs'
|
||||||
|
|
||||||
const localStoragePageUrl = `https://www.zhipin.com/desktop/`
|
const localStoragePageUrl = `https://www.zhipin.com/desktop/`
|
||||||
const bossChatUiUrl = `https://www.zhipin.com/web/geek/chat`
|
const bossChatUiUrl = `https://www.zhipin.com/web/geek/chat`
|
||||||
const bossCookies = readStorageFile('boss-cookies.json')
|
const bossCookies = readStorageFile('boss-cookies.json')
|
||||||
const bossLocalStorage = readStorageFile('boss-local-storage.json')
|
const bossLocalStorage = readStorageFile('boss-local-storage.json')
|
||||||
|
|
||||||
puppeteer.use(StealthPlugin())
|
|
||||||
|
|
||||||
export async function bootstrap() {
|
export async function bootstrap() {
|
||||||
|
const { puppeteer } = await initPuppeteer()
|
||||||
|
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
headless: false,
|
headless: false,
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user