diff --git a/src/components/SidebarPanel.tsx b/src/components/SidebarPanel.tsx index 73e8775..7e5882c 100644 --- a/src/components/SidebarPanel.tsx +++ b/src/components/SidebarPanel.tsx @@ -6,7 +6,7 @@ import { useState, useEffect } from "react" import { getCookieValue } from "~utils/cookie" -import { getCustomizeResume, getFormFillAnswer } from "~api/aiApi" +import { getCustomizeResume } from "~api/aiApi" import { fillMatchedField, delay, isSearchPickerField, fillSearchPickerField, isTimePeriodField, isTimeSingleField, fillTimePeriodField, fillTimeSingleField } from "~lib/autofill" import { extractDomStructure, detectPageLanguage, isJobApplicationForm } from "~lib/dom" import { matchFormFields, matchFormFieldsInRange, matchMainFields } from "~lib/formMatcher" @@ -67,7 +67,7 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps) }) } }) - }, []) + }, [jobInfo?.id]) /** * 自动填写按钮点击处理 @@ -479,60 +479,14 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps) usedInputs.add(inp) } - console.log(` 收集到 ${unmatchedFields.length} 个待AI填写的空白字段`) + console.log(` 收集到 ${unmatchedFields.length} 个待填写的空白字段`) - // 逐个调用AI接口获取填充值并填写 - if (unmatchedFields.length > 0) { - for (const uf of unmatchedFields) { - try { - const aiAnswer = await getFormFillAnswer({ - jobId: jobInfo?.id || 0, - label: uf.labelText, - type: uf.formType, - }) - if (aiAnswer) { - uf.fillValue = String(aiAnswer) - console.log(` [AI] "${uf.labelText}" → "${uf.fillValue}" (type: ${uf.formType})`) - - // 填写到页面 - if (uf.inputElement) { - if (uf.isPicker) { - // 选择器类型:构造 MatchedFormField 走选择器填写逻辑 - const pickerField: MatchedFormField = { - key: "", section: "main", resumeField: "", sectionIndex: 0, - labelText: uf.labelText, labelElement: uf.labelElement, - labelSelector: "", inputElement: uf.inputElement, - inputSelector: "", buttonElement: null, buttonSelector: "", - inputType: "picker", radioContainer: null, - isPicker: true, pickerDropdownElement: null, - pickerDropdownSelector: "", fillValue: uf.fillValue, - } - await detectPickerField(pickerField, lang) - const ok = await fillMatchedField(pickerField) - if (ok) success++; else failed++ - } else { - // 普通输入框:直接写入 - const { forceSetValue } = await import("~lib/autofill") - uf.inputElement.focus() - await delay(50) - forceSetValue(uf.inputElement, uf.fillValue) - success++ - console.log(` [AI] ✅ 已填写 "${uf.labelText}" = "${uf.fillValue}"`) - } - } - } else { - console.log(` [AI] "${uf.labelText}" 接口未返回填充值,跳过`) - skipped++ - } - } catch (err) { - console.warn(` [AI] "${uf.labelText}" 接口调用失败:`, err) - failed++ - } - await delay(300) - } + // 打印收集到的空白字段详情 + for (const uf of unmatchedFields) { + console.log(` [待填写] "${uf.labelText}" | formType: ${uf.formType} | isPicker: ${uf.isPicker}`) } - console.log(`===== OfferPie: 阶段C完成 总计成功${success} 失败${failed} 跳过${skipped} =====`) + console.log(`===== OfferPie: 阶段C完成 收集到 ${unmatchedFields.length} 个空白字段 =====`) } else { setFormFields([]) console.log("===== OfferPie: 当前页面不是职位申请表单,跳过字段匹配 =====") @@ -548,7 +502,7 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
{/* 顶部操作栏:关闭按钮始终显示,反馈和设置仅登录后显示 */}
- {isLoggedIn && 反馈12} + {isLoggedIn && 反馈12345} {isLoggedIn && 设置}