add common-job-condition-config migrate logic; add commonJobConditionConfig fill back logic

This commit is contained in:
geekgeekrun
2026-02-20 16:08:41 +08:00
parent 8506921ef2
commit 31236acda4
4 changed files with 133 additions and 18 deletions

View File

@@ -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
}
}

View File

@@ -0,0 +1,13 @@
{
"expectCityList": [],
"expectJobNameRegExpStr": "",
"expectJobTypeRegExpStr": "",
"expectJobDescRegExpStr": "",
"expectCompanies": [],
"blockCompanyNameRegExpStr": "",
"jobDetailRegExpMatchLogic": 1,
"expectSalaryCalculateWay": 1,
"expectSalaryLow": null,
"expectSalaryHigh": null
}

View File

@@ -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'

View File

@@ -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()