perf : 再次优化岗位信息薪资部分解析

This commit is contained in:
2025-12-25 16:21:36 +08:00
parent 0704896694
commit 5ab136f1c5
3 changed files with 47 additions and 14 deletions

View File

@@ -237,11 +237,22 @@ function extractSpeechText(markdown) {
markdown.slice(lastJobEndIndex).trim() : '';
const jobTexts = jobs.map((job, index) => {
// 处理薪资格式:将 "数字-数字" 中的 '-' 替换为 '到'
// 处理薪资格式
let salaryText = job.salary;
if (salaryText) {
// 匹配 "数字-数字" 格式15000-18000元/月)
salaryText = salaryText.replace(/(\d+)-(\d+)/g, '$1到$2');
if (salaryText) {
// 匹配 "XXXXX-XXXXX元/月" 格式
const rangeMatch = salaryText.match(/(\d+)-(\d+)元\/月/);
if (rangeMatch) {
const minSalary = parseInt(rangeMatch[1], 10);
const maxSalary = parseInt(rangeMatch[2], 10);
// 转换为千位单位
const minK = Math.round(minSalary / 1000);
const maxK = Math.round(maxSalary / 1000);
salaryText = `${minK}千到${maxK}千每月`;
}
// 如果不是 "XXXXX-XXXXX元/月" 格式,保持原样
}
return `${index + 1} 个岗位,岗位名称是:${job.jobTitle},公司是:${job.companyName},薪资:${salaryText},地点:${job.location},学历要求:${job.education},经验要求:${job.experience}`;
@@ -253,4 +264,4 @@ function extractSpeechText(markdown) {
if (endingText) finalTextParts.push(endingText);
return finalTextParts.join('\n');
}
}