From 31236acda4a824ab5bd3311b92ab4007d1da2f97 Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Fri, 20 Feb 2026 16:08:41 +0800 Subject: [PATCH] add `common-job-condition-config` migrate logic; add commonJobConditionConfig fill back logic --- .../default-config-file/boss.json | 12 +- .../common-job-condition-config.json | 13 +++ .../runtime-file-utils.mjs | 104 +++++++++++++++--- .../GeekAutoStartChatWithBoss/index.vue | 22 ++++ 4 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 packages/geek-auto-start-chat-with-boss/default-config-file/common-job-condition-config.json diff --git a/packages/geek-auto-start-chat-with-boss/default-config-file/boss.json b/packages/geek-auto-start-chat-with-boss/default-config-file/boss.json index 2b202d4..66b1005 100644 --- a/packages/geek-auto-start-chat-with-boss/default-config-file/boss.json +++ b/packages/geek-auto-start-chat-with-boss/default-config-file/boss.json @@ -11,6 +11,9 @@ "staticCombineRecommendJobFilterConditions": [], "isSkipEmptyConditionForCombineRecommendJobFilter": false, "expectJobRegExpStr": "", + "expectJobNameRegExpStr": "", + "expectJobTypeRegExpStr": "", + "expectJobDescRegExpStr": "", "jobNotMatchStrategy": 1, "jobNotActiveStrategy": 1, "markAsNotActiveSelectedTimeRange": 7, @@ -36,5 +39,12 @@ "isSageTimeEnabled": true, "sageTimeOpTimes": 100, "sageTimePauseMinute": 15, - "blockCompanyNameRegExpStr": "" + "blockCompanyNameRegExpStr": "", + "fieldsForUseCommonConfig": { + "city": true, + "salary": true, + "jobDetail": true, + "blockCompanyNameRegExpStr": true, + "expectCompanies": true + } } \ No newline at end of file diff --git a/packages/geek-auto-start-chat-with-boss/default-config-file/common-job-condition-config.json b/packages/geek-auto-start-chat-with-boss/default-config-file/common-job-condition-config.json new file mode 100644 index 0000000..c70ad95 --- /dev/null +++ b/packages/geek-auto-start-chat-with-boss/default-config-file/common-job-condition-config.json @@ -0,0 +1,13 @@ +{ + "expectCityList": [], + "expectJobNameRegExpStr": "", + "expectJobTypeRegExpStr": "", + "expectJobDescRegExpStr": "", + "expectCompanies": [], + "blockCompanyNameRegExpStr": "", + "jobDetailRegExpMatchLogic": 1, + "expectSalaryCalculateWay": 1, + "expectSalaryLow": null, + "expectSalaryHigh": null + +} \ No newline at end of file diff --git a/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs b/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs index dd9512a..abb0f5c 100644 --- a/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs +++ b/packages/geek-auto-start-chat-with-boss/runtime-file-utils.mjs @@ -11,16 +11,100 @@ import defaultLlmConf from './default-config-file/llm.json' assert { type: 'json import defaultBossCookieStorage from './default-storage-file/boss-cookies.json' assert { type: 'json' } import defaultBossLocalStorageStorage from './default-storage-file/boss-local-storage.json' assert { type: 'json' } import defaultJobNotSuitReasonCodeToTextCacheStorage from './default-storage-file/job-not-suit-reason-code-to-text-cache.json' assert { type: 'json' } -export const configFileNameList = ['boss.json', 'dingtalk.json', 'target-company-list.json', 'llm.json'] +import defaultCommonJobConditionConfig from './default-config-file/common-job-condition-config.json' assert { type: 'json' } +export const configFileNameList = ['boss.json', 'dingtalk.json', 'target-company-list.json', 'llm.json', 'common-job-condition-config.json'] const defaultConfigFileContentMap = { 'boss.json': JSON.stringify(defaultBossConf), 'dingtalk.json': JSON.stringify(defaultDingtalkConf), 'target-company-list.json': JSON.stringify(defaultTargetCompanyListConf), - 'llm.json': JSON.stringify(defaultLlmConf) + 'llm.json': JSON.stringify(defaultLlmConf), + 'common-job-condition-config.json': JSON.stringify(defaultCommonJobConditionConfig) +} +const runtimeFolderPath = path.join(os.homedir(), '.geekgeekrun') +export const configFolderPath = path.join( + runtimeFolderPath, + 'config' +) +export const writeConfigFile = async (fileName, content, { isSync } = {}) => { + const filePath = path.join(configFolderPath, fileName) + const fileContent = JSON.stringify(content) + if (isSync) { + fs.writeFileSync( + filePath, + fileContent + ) + } + else { + return fsPromise.writeFile( + filePath, + fileContent + ) + } +} +if ( + !fs.existsSync( + path.join(configFolderPath, 'common-job-condition-config.json') + ) +) { + let bossConfig = null + if ( + fs.existsSync( + path.join(configFolderPath, 'boss.json') + ) + ) { + fs.existsSync( + path.join(configFolderPath, 'boss.json') + ) + try { + bossConfig = JSON.parse( + fs.readFileSync( + path.join(configFolderPath, 'boss.json') + ) + ) + } + catch {} + } + if (bossConfig) { + Object.keys(defaultCommonJobConditionConfig).forEach( + key => { + if (Object.hasOwn(bossConfig, key)) { + defaultCommonJobConditionConfig[key] = bossConfig[key] + } + } + ) + } + let targetCompanyList = null + if ( + fs.existsSync( + path.join(configFolderPath, 'target-company-list.json') + ) + ) { + targetCompanyList = JSON.parse( + fs.readFileSync( + path.join(configFolderPath, 'target-company-list.json') + ) + ) + } + if (targetCompanyList) { + defaultCommonJobConditionConfig.expectCompanies = targetCompanyList ?? [] + } + writeConfigFile('common-job-condition-config.json', defaultCommonJobConditionConfig, { isSync: true }) + if (bossConfig) { + if (!bossConfig.fieldsForUseCommonConfig) { + bossConfig.fieldsForUseCommonConfig = {} + } + Object.assign(bossConfig.fieldsForUseCommonConfig, { + city: true, + salary: true, + jobDetail: true, + blockCompanyNameRegExpStr: true, + expectCompanies: true + }) + writeConfigFile('boss.json', bossConfig, { isSync: true }) + } } -const runtimeFolderPath = path.join(os.homedir(), '.geekgeekrun') const ensureRuntimeFolderPathExist = () => { if (!fs.existsSync(runtimeFolderPath)) { fs.mkdirSync(runtimeFolderPath) @@ -35,11 +119,6 @@ const ensureRuntimeFolderPathExist = () => { } }) } - -export const configFolderPath = path.join( - runtimeFolderPath, - 'config' -) export const ensureConfigFileExist = () => { ensureRuntimeFolderPathExist() ;configFileNameList.forEach( @@ -82,15 +161,6 @@ export const readConfigFile = (fileName) => { return o } -export const writeConfigFile = async (fileName, content) => { - const filePath = path.join(configFolderPath, fileName) - const fileContent = JSON.stringify(content) - return fsPromise.writeFile( - filePath, - fileContent - ) -} - export const storageFilePath = path.join( runtimeFolderPath, 'storage' diff --git a/packages/ui/src/renderer/src/page/MainLayout/GeekAutoStartChatWithBoss/index.vue b/packages/ui/src/renderer/src/page/MainLayout/GeekAutoStartChatWithBoss/index.vue index a6a147e..a4aa5ce 100644 --- a/packages/ui/src/renderer/src/page/MainLayout/GeekAutoStartChatWithBoss/index.vue +++ b/packages/ui/src/renderer/src/page/MainLayout/GeekAutoStartChatWithBoss/index.vue @@ -1929,6 +1929,28 @@ electron.ipcRenderer.invoke('fetch-config-file-content').then((res) => { res.config['boss.json'].blockCompanyNameRegMatchStrategy ?? MarkAsNotSuitOp.NO_OP formContent.value.fieldsForUseCommonConfig = res.config['boss.json']?.fieldsForUseCommonConfig ?? {} + + commonJobConditionConfig.value = { + expectJobNameRegExpStr: + res.config['common-job-condition-config.json']?.expectJobNameRegExpStr ?? '', + expectJobTypeRegExpStr: + res.config['common-job-condition-config.json']?.expectJobTypeRegExpStr ?? '', + expectJobDescRegExpStr: + res.config['common-job-condition-config.json']?.expectJobDescRegExpStr ?? '', + jobDetailRegExpMatchLogic: + res.config['common-job-condition-config.json']?.jobDetailRegExpMatchLogic ?? + JobDetailRegExpMatchLogic.EVERY, + expectCompanies: (res.config['common-job-condition-config.json']?.expectCompanies ?? []).join( + ',' + ), + blockCompanyNameRegExpStr: + res.config['common-job-condition-config.json']?.blockCompanyNameRegExpStr ?? '', + expectSalaryCalculateWay: + res.config['common-job-condition-config.json']?.expectSalaryCalculateWay ?? + SalaryCalculateWay.MONTH_SALARY, + expectSalaryLow: res.config['common-job-condition-config.json']?.expectSalaryLow ?? null, + expectSalaryHigh: res.config['common-job-condition-config.json']?.expectSalaryHigh ?? null + } }) const jobSourceFormItemSectionEl = ref()