mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-06 20:02:47 +08:00
add listener for common-job-condition-config-updated; enhance common config show in ghosting reminder ui
This commit is contained in:
@@ -9,5 +9,4 @@
|
||||
"expectSalaryCalculateWay": 1,
|
||||
"expectSalaryLow": null,
|
||||
"expectSalaryHigh": null
|
||||
|
||||
}
|
||||
32
packages/ui/src/main/features/common-job-condition.ts
Normal file
32
packages/ui/src/main/features/common-job-condition.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ipcMain } from 'electron'
|
||||
import { createCommonJobConditionConfigWindow } from '../window/commonJobConditionConfigWindow'
|
||||
import { mainWindow } from '../window/mainWindow'
|
||||
import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
|
||||
let commonJobConditionConfigWindow = null
|
||||
export async function waitForCommonJobConditionDone() {
|
||||
return new Promise((resolve, reject) => {
|
||||
commonJobConditionConfigWindow = createCommonJobConditionConfigWindow({
|
||||
parent: mainWindow!,
|
||||
modal: true,
|
||||
show: true
|
||||
})
|
||||
let processDone = false
|
||||
function handler() {
|
||||
processDone = true
|
||||
commonJobConditionConfigWindow.close()
|
||||
}
|
||||
ipcMain.once('common-job-condition-config-done', handler)
|
||||
commonJobConditionConfigWindow.on('closed', async () => {
|
||||
ipcMain.off('common-job-condition-config-done', handler)
|
||||
if (processDone) {
|
||||
mainWindow?.webContents.send('common-job-condition-config-updated', {
|
||||
config: await readConfigFile('common-job-condition-config.json')
|
||||
})
|
||||
resolve(true)
|
||||
} else {
|
||||
reject(new Error('USER_CANCELLED'))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -2,8 +2,6 @@ import { ipcMain, shell, app, dialog, BrowserWindow } from 'electron'
|
||||
import path from 'path'
|
||||
import * as childProcess from 'node:child_process'
|
||||
import {
|
||||
ensureConfigFileExist,
|
||||
configFileNameList,
|
||||
readConfigFile,
|
||||
writeConfigFile,
|
||||
readStorageFile,
|
||||
@@ -58,24 +56,10 @@ import {
|
||||
waitForUserApproveAgreement
|
||||
} from '../../../features/first-launch-notice-window'
|
||||
import { getLastUsedAndAvailableBrowser } from '../../DOWNLOAD_DEPENDENCIES/utils/browser-history'
|
||||
import { createCommonJobConditionConfigWindow } from '../../../window/commonJobConditionConfigWindow'
|
||||
import { waitForCommonJobConditionDone } from '../../../features/common-job-condition'
|
||||
import { ensureConfigFileExist } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
|
||||
export default function initIpc() {
|
||||
ipcMain.handle('fetch-config-file-content', async () => {
|
||||
const configFileContentList = configFileNameList.map((fileName) => {
|
||||
return readConfigFile(fileName)
|
||||
})
|
||||
const result = {
|
||||
config: {}
|
||||
}
|
||||
|
||||
configFileNameList.forEach((fileName, index) => {
|
||||
result.config[fileName] = configFileContentList[index]
|
||||
})
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
ipcMain.handle('save-config-file-from-ui', async (ev, payload) => {
|
||||
payload = JSON.parse(payload)
|
||||
ensureConfigFileExist()
|
||||
@@ -612,11 +596,7 @@ export default function initIpc() {
|
||||
}
|
||||
})
|
||||
ipcMain.handle('common-job-condition-config', async () => {
|
||||
createCommonJobConditionConfigWindow({
|
||||
parent: mainWindow!,
|
||||
modal: true,
|
||||
show: true
|
||||
})
|
||||
await waitForCommonJobConditionDone()
|
||||
})
|
||||
|
||||
ipcMain.handle('exit-app-immediately', () => {
|
||||
|
||||
@@ -5,8 +5,10 @@ import os from 'node:os'
|
||||
import fs from 'node:fs'
|
||||
import {
|
||||
ensureStorageFileExist,
|
||||
readStorageFile,
|
||||
writeStorageFile
|
||||
writeStorageFile,
|
||||
configFileNameList,
|
||||
readConfigFile,
|
||||
readStorageFile
|
||||
} from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
|
||||
export default function initPublicIpc() {
|
||||
@@ -110,4 +112,19 @@ export default function initPublicIpc() {
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
ipcMain.handle('fetch-config-file-content', async () => {
|
||||
const configFileContentList = configFileNameList.map((fileName) => {
|
||||
return readConfigFile(fileName)
|
||||
})
|
||||
const result = {
|
||||
config: {}
|
||||
}
|
||||
|
||||
configFileNameList.forEach((fileName, index) => {
|
||||
result.config[fileName] = configFileContentList[index]
|
||||
})
|
||||
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { BrowserWindow, ipcMain } from 'electron'
|
||||
import path from 'path'
|
||||
import { writeConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
|
||||
export let commonJobConditionConfigWindow: BrowserWindow | null = null
|
||||
export function createCommonJobConditionConfigWindow(
|
||||
@@ -42,5 +43,13 @@ export function createCommonJobConditionConfigWindow(
|
||||
commonJobConditionConfigWindow = null
|
||||
})
|
||||
|
||||
ipcMain.handle('save-common-job-condition-config', async (_ev, payload) => {
|
||||
await writeConfigFile('common-job-condition-config.json', payload)
|
||||
commonJobConditionConfigWindow!.close()
|
||||
})
|
||||
commonJobConditionConfigWindow!.once('closed', () => {
|
||||
ipcMain.removeHandler('save-common-job-condition-config')
|
||||
})
|
||||
|
||||
return commonJobConditionConfigWindow!
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { gtagRenderer as baseGtagRenderer } from '@renderer/utils/gtag'
|
||||
import { SalaryCalculateWay } from '@geekgeekrun/sqlite-plugin/src/enums'
|
||||
import { JobDetailRegExpMatchLogic, SalaryCalculateWay } from '@geekgeekrun/sqlite-plugin/src/enums'
|
||||
import CityChooser from '../MainLayout/GeekAutoStartChatWithBoss/components/CityChooser.vue'
|
||||
import { QuestionFilled, ArrowDown } from '@element-plus/icons-vue'
|
||||
|
||||
@@ -618,18 +618,19 @@ import {
|
||||
normalizeCommaSplittedStr
|
||||
} from '../MainLayout/GeekAutoStartChatWithBoss/common'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import expectJobFilterTemplateList from '../MainLayout/GeekAutoStartChatWithBoss/expectJobFilterTemplateList'
|
||||
|
||||
const { ipcRenderer } = window.electron
|
||||
const gtagRenderer = (name, params?: object) => {
|
||||
return baseGtagRenderer(name, {
|
||||
scene: 'cjc_config',
|
||||
...params
|
||||
})
|
||||
}
|
||||
const router = useRouter()
|
||||
|
||||
const formContent = ref({
|
||||
expectCompanies: '',
|
||||
expectCityList: [],
|
||||
jobDetailRegExpMatchLogic: JobDetailRegExpMatchLogic.EVERY,
|
||||
expectJobNameRegExpStr: '',
|
||||
expectJobTypeRegExpStr: '',
|
||||
expectJobDescRegExpStr: '',
|
||||
@@ -697,8 +698,32 @@ function handleCancel() {
|
||||
const formRef = ref()
|
||||
async function handleSave() {
|
||||
await formRef.value?.validate()
|
||||
//
|
||||
await ipcRenderer.invoke(
|
||||
'save-common-job-condition-config',
|
||||
JSON.parse(
|
||||
JSON.stringify({
|
||||
...formContent.value,
|
||||
expectCompanies: formContent.value.expectCompanies
|
||||
? formContent.value.expectCompanies.split(',').map((s) => s.trim())
|
||||
: []
|
||||
})
|
||||
)
|
||||
)
|
||||
ipcRenderer.send('common-job-condition-config-done')
|
||||
}
|
||||
|
||||
ipcRenderer.invoke('fetch-config-file-content').then((res) => {
|
||||
const commonJobConditionConfig = res.config?.['common-job-condition-config.json'] ?? {}
|
||||
Object.keys(formContent.value).forEach((key) => {
|
||||
if (key in commonJobConditionConfig) {
|
||||
if (key === 'expectCompanies') {
|
||||
formContent.value[key] = (commonJobConditionConfig[key] ?? []).join(',')
|
||||
} else {
|
||||
formContent.value[key] = commonJobConditionConfig[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -2340,9 +2340,12 @@ const handleBlockCompanyNameRegExpTemplateClicked =
|
||||
|
||||
const commonJobConditionConfig = ref({})
|
||||
const unListenCommonJobConditionConfig = ipcRenderer.on(
|
||||
'common-job-condition-config-changed',
|
||||
(_, config) => {
|
||||
commonJobConditionConfig.value = config
|
||||
'common-job-condition-config-updated',
|
||||
(_, { config }) => {
|
||||
commonJobConditionConfig.value = {
|
||||
...config,
|
||||
expectCompanies: config?.expectCompanies?.map((it) => it.trim())?.join(',') ?? ''
|
||||
}
|
||||
}
|
||||
)
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
>
|
||||
<el-form-item>
|
||||
<div>
|
||||
<el-checkbox v-if="!expectJobTypeRegExpStr?.trim()" :model-value="false" disabled>
|
||||
<el-checkbox
|
||||
v-if="!expectJobTypeRegExpStrForRender?.trim()"
|
||||
:model-value="false"
|
||||
disabled
|
||||
>
|
||||
发送提醒消息前,先按照“自动开聊-职位类型正则”校验正在与BOSS沟通的岗位是否满足期望,校验通过后再提醒
|
||||
</el-checkbox>
|
||||
<template v-else>
|
||||
@@ -17,7 +21,7 @@
|
||||
发送提醒消息前,先按照“自动开聊-职位类型正则”校验正在与BOSS沟通的岗位是否满足期望,校验通过后再提醒
|
||||
</el-checkbox>
|
||||
<div ml1.5em color-gray>
|
||||
<div>当前职位类型正则:{{ expectJobTypeRegExpStr?.trim() }}</div>
|
||||
<div>当前职位类型正则:{{ expectJobTypeRegExpStrForRender?.trim() }}</div>
|
||||
<template
|
||||
v-if="
|
||||
formContent.autoReminder.rechatContentSource ===
|
||||
@@ -33,7 +37,11 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div>
|
||||
<el-checkbox v-if="!blockCompanyNameRegExpStr?.trim()" :model-value="false" disabled>
|
||||
<el-checkbox
|
||||
v-if="!blockCompanyNameRegExpStrForRender?.trim()"
|
||||
:model-value="false"
|
||||
disabled
|
||||
>
|
||||
发送提醒消息前,先按照“自动开聊-不期望投递公司正则”校验正在与BOSS沟通的岗位是否归属于不期望投递的公司,如果是,则不提醒
|
||||
</el-checkbox>
|
||||
<template v-else>
|
||||
@@ -41,7 +49,7 @@
|
||||
发送提醒消息前,先按照“自动开聊-不期望投递公司正则”校验正在与BOSS沟通的岗位是否归属于不期望投递的公司,如果是,则不提醒
|
||||
</el-checkbox>
|
||||
<div ml1.5em color-gray>
|
||||
<div>当前不期望投递公司正则:{{ blockCompanyNameRegExpStr?.trim() }}</div>
|
||||
<div>当前不期望投递公司正则:{{ blockCompanyNameRegExpStrForRender?.trim() }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -313,10 +321,13 @@ electron.ipcRenderer.invoke('fetch-config-file-content').then((res) => {
|
||||
|
||||
const expectJobTypeRegExpStr = ref('')
|
||||
const blockCompanyNameRegExpStr = ref('')
|
||||
const fieldsForUseCommonConfig = ref({})
|
||||
async function fetchAutoStartChatConfig() {
|
||||
await electron.ipcRenderer.invoke('fetch-config-file-content').then((res) => {
|
||||
expectJobTypeRegExpStr.value = res.config['boss.json']?.expectJobTypeRegExpStr
|
||||
blockCompanyNameRegExpStr.value = res.config['boss.json']?.blockCompanyNameRegExpStr
|
||||
fieldsForUseCommonConfig.value = res.config['boss.json']?.fieldsForUseCommonConfig ?? {}
|
||||
commonJobConditionConfig.value = res.config['common-job-condition-config.json']
|
||||
})
|
||||
}
|
||||
fetchAutoStartChatConfig()
|
||||
@@ -324,6 +335,30 @@ mittBus.on('auto-start-chat-with-boss-config-saved', fetchAutoStartChatConfig)
|
||||
onUnmounted(() => {
|
||||
mittBus.off('auto-start-chat-with-boss-config-saved', fetchAutoStartChatConfig)
|
||||
})
|
||||
const commonJobConditionConfig = ref({})
|
||||
const unListenCommonJobConditionConfig = electron.ipcRenderer.on(
|
||||
'common-job-condition-config-updated',
|
||||
(_, { config }) => {
|
||||
commonJobConditionConfig.value = {
|
||||
...config,
|
||||
expectCompanies: config?.expectCompanies?.map((it) => it.trim())?.join(',') ?? ''
|
||||
}
|
||||
}
|
||||
)
|
||||
onUnmounted(() => {
|
||||
unListenCommonJobConditionConfig()
|
||||
})
|
||||
|
||||
const expectJobTypeRegExpStrForRender = computed(() => {
|
||||
return !fieldsForUseCommonConfig.value.jobDetail
|
||||
? expectJobTypeRegExpStr.value
|
||||
: commonJobConditionConfig.value.expectJobTypeRegExpStr
|
||||
})
|
||||
const blockCompanyNameRegExpStrForRender = computed(() => {
|
||||
return !fieldsForUseCommonConfig.value.blockCompanyNameRegExpStr
|
||||
? blockCompanyNameRegExpStr.value
|
||||
: commonJobConditionConfig.value.blockCompanyNameRegExpStr
|
||||
})
|
||||
|
||||
const resumeContent = ref(null)
|
||||
async function fetchResumeContent() {
|
||||
|
||||
Reference in New Issue
Block a user