经历识别添加

This commit is contained in:
2026-05-09 18:56:54 +08:00
parent 1430b38b20
commit 888d4450f1
3 changed files with 707 additions and 16 deletions
+11 -11
View File
@@ -12,6 +12,7 @@ import { detectPickerField } from "~lib/pickerDetector"
import { detectAndUploadResume } from "~lib/resumeUpload"
import { getMockResumeData } from "~lib/constants"
import { getResumeFieldValue } from "~lib/resumeDataHelper"
import { locateExperienceSections, expandExperienceSections } from "~lib/experienceSection"
import type { MatchedFormField, ResumeData } from "~lib/types"
import "./SidebarPanel.scss"
@@ -63,18 +64,17 @@ export function SidebarPanel({ onClose }: SidebarPanelProps) {
setResumeData(currentResumeData)
console.log(`===== OfferPie: 已加载简历数据,教育${currentResumeData.education.length}段 工作${currentResumeData.work.length}段 实习${currentResumeData.internship.length}段 项目${currentResumeData.project.length}段 竞赛${currentResumeData.competition.length}段 =====`)
// 4.1 检测并上传简历文件
const resumeUrl = "https://offerpie.oss-cn-guangzhou.aliyuncs.com/%E4%BA%8E%E5%A4%A7%E6%98%A5.pdf"
const uploaded = await detectAndUploadResume(resumeUrl)
console.log(`===== OfferPie: 简历上传 ${uploaded ? "成功" : "跳过(未找到上传按钮或失败)"} =====`)
if (uploaded) await delay(1000) // 等待网站解析简历
// // 4.1 检测并上传简历文件
// const resumeUrl = "https://offerpie.oss-cn-guangzhou.aliyuncs.com/%E4%BA%8E%E5%A4%A7%E6%98%A5.pdf"
// const uploaded = await detectAndUploadResume(resumeUrl)
// console.log(`===== OfferPie: 简历上传 ${uploaded ? "成功" : "跳过(未找到上传按钮或失败)"} =====`)
// if (uploaded) await delay(1000) // 等待网站解析简历
// 4.5 查找教育背景(教育经历)、实习经历、工作经历、项目经历、竞赛经历位置和添加按钮,根据要填的简历数据添加相应的经历条
// 4.5 定位经历区块并统计已展开段
const sectionResults = locateExperienceSections(document.body, lang)
// 4.6 对比简历数据段数,点击添加按钮补足不够的段数
const expandedResults = await expandExperienceSections(sectionResults, currentResumeData, lang)
// TODO: 后续实现步骤:
// 1. 遍历 EXPERIENCE_SECTION_CONFIGS,在 DOM 中查找每种经历的区块标题元素
// 2. 对比简历数据中该经历的段数 vs 页面已展开的段数
// 3. 如果简历数据段数 > 页面已展开段数,查找并点击"添加"按钮补足差额
// 4. 每次点击添加按钮后等待 DOM 更新,重新计数确认
// 5. 对5种经历的标签关系数据做特殊标记(后续完善)
// 6. 所有经历段数添加完毕后,再进入统一的字段匹配和填写流程
@@ -151,7 +151,7 @@ export function SidebarPanel({ onClose }: SidebarPanelProps) {
<div className="op-container">
{/* 顶部操作栏:反馈、设置、关闭按钮 */}
<div className="op-header">
<span className="op-header-link">3</span>
<span className="op-header-link">5</span>
<span className="op-header-link"></span>
{/* 关闭按钮:点击后隐藏侧边栏 */}
<button className="op-close-btn" onClick={onClose}>