add logic that launch auto start chat from render process

This commit is contained in:
bossgeekgo
2024-02-12 17:41:25 +08:00
parent 9f2090ac45
commit 275138a885
2 changed files with 18 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { BrowserWindow, ipcMain, shell } from 'electron'
import path from 'path'
import * as childProcess from 'node:child_process'
import { is } from '@electron-toolkit/utils'
import {
readConfigFile,
@@ -7,6 +8,7 @@ import {
ensureConfigFileExist,
writeConfigFile
} from '@bossgeekgo/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
import { ChildProcess } from 'child_process'
let mainWindow: BrowserWindow
export function createMainWindow(): void {
@@ -74,4 +76,19 @@ export function createMainWindow(): void {
writeConfigFile('target-company-list.json', payload.expectCompanies.split(','))
])
})
// const currentExecutablePath = app.getPath('exe')
// console.log(currentExecutablePath)
let subProcessOfPuppeteer: ChildProcess
ipcMain.handle('run-geek-auto-start-chat-with-boss', async () => {
console.log(process)
subProcessOfPuppeteer = childProcess.spawn(process.argv[0], process.argv.slice(1), {
env: {
...process.env,
MAIN_BOSSGEEKGO_RUN_MODE: 'geekAutoStartWithBoss'
}
})
console.log(subProcessOfPuppeteer)
})
}

View File

@@ -77,6 +77,7 @@ const formRef = ref<InstanceType<typeof ElForm>>()
const handleSubmit = async () => {
await formRef.value!.validate()
await electron.ipcRenderer.invoke('save-config-file-from-ui', JSON.stringify(formContent.value))
await electron.ipcRenderer.invoke('run-geek-auto-start-chat-with-boss', JSON.stringify(formContent.value))
}
const handleSave = async () => {
await formRef.value!.validate()