From 8c67dcb5a9ce850818db16a1124dd77c0041e4c9 Mon Sep 17 00:00:00 2001 From: xuxin <15279969124@163.com> Date: Wed, 10 Jun 2026 11:00:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=A1=A8=E5=8D=95AI=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=AD=94=E6=A1=88=E7=9A=84=E6=8E=A5=E5=85=A5=EF=BC=8C?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=A1=A8=E5=8D=95=E5=A1=AB=E5=86=99=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9D=A5=E6=BA=90=E5=8F=AA=E8=83=BD=E6=98=AF=E7=AE=80?= =?UTF-8?q?=E5=8E=86=E6=88=96=E5=85=B6=E4=BB=96=E9=A2=84=E8=AE=BE=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SidebarPanel.tsx | 62 +++++---------------------------- src/contents/sidebar.tsx | 21 +++++++++-- 2 files changed, 27 insertions(+), 56 deletions(-) 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 && 设置}