去掉表单AI生成答案的接入,所有表单填写内容来源只能是简历或其他预设字段
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect } from "react"
|
||||||
import { getCookieValue } from "~utils/cookie"
|
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 { fillMatchedField, delay, isSearchPickerField, fillSearchPickerField, isTimePeriodField, isTimeSingleField, fillTimePeriodField, fillTimeSingleField } from "~lib/autofill"
|
||||||
import { extractDomStructure, detectPageLanguage, isJobApplicationForm } from "~lib/dom"
|
import { extractDomStructure, detectPageLanguage, isJobApplicationForm } from "~lib/dom"
|
||||||
import { matchFormFields, matchFormFieldsInRange, matchMainFields } from "~lib/formMatcher"
|
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)
|
usedInputs.add(inp)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(` 收集到 ${unmatchedFields.length} 个待AI填写的空白字段`)
|
console.log(` 收集到 ${unmatchedFields.length} 个待填写的空白字段`)
|
||||||
|
|
||||||
// 逐个调用AI接口获取填充值并填写
|
// 打印收集到的空白字段详情
|
||||||
if (unmatchedFields.length > 0) {
|
for (const uf of unmatchedFields) {
|
||||||
for (const uf of unmatchedFields) {
|
console.log(` [待填写] "${uf.labelText}" | formType: ${uf.formType} | isPicker: ${uf.isPicker}`)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`===== OfferPie: 阶段C完成 总计成功${success} 失败${failed} 跳过${skipped} =====`)
|
console.log(`===== OfferPie: 阶段C完成 收集到 ${unmatchedFields.length} 个空白字段 =====`)
|
||||||
} else {
|
} else {
|
||||||
setFormFields([])
|
setFormFields([])
|
||||||
console.log("===== OfferPie: 当前页面不是职位申请表单,跳过字段匹配 =====")
|
console.log("===== OfferPie: 当前页面不是职位申请表单,跳过字段匹配 =====")
|
||||||
@@ -548,7 +502,7 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
|
|||||||
<div className="op-container">
|
<div className="op-container">
|
||||||
{/* 顶部操作栏:关闭按钮始终显示,反馈和设置仅登录后显示 */}
|
{/* 顶部操作栏:关闭按钮始终显示,反馈和设置仅登录后显示 */}
|
||||||
<div className="op-header">
|
<div className="op-header">
|
||||||
{isLoggedIn && <span className="op-header-link">反馈12</span>}
|
{isLoggedIn && <span className="op-header-link">反馈12345</span>}
|
||||||
{isLoggedIn && <span className="op-header-link">设置</span>}
|
{isLoggedIn && <span className="op-header-link">设置</span>}
|
||||||
<button className="op-close-btn" onClick={onClose}>
|
<button className="op-close-btn" onClick={onClose}>
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round">
|
||||||
|
|||||||
@@ -51,19 +51,36 @@ function Sidebar() {
|
|||||||
console.log("[OfferPie] 页面加载时获取到的 Token:", token)
|
console.log("[OfferPie] 页面加载时获取到的 Token:", token)
|
||||||
if (!token) return
|
if (!token) return
|
||||||
|
|
||||||
// 有 token 时,先查询岗位信息,有岗位才自动打开面板
|
// 确定用于查询岗位信息的 URL:优先用 sessionStorage 缓存的(同标签页跳转后保留)
|
||||||
findJobBySourceUrl(currentUrl).then((data) => {
|
const STORAGE_KEY = "offerpie_source_url"
|
||||||
|
const cachedUrl = sessionStorage.getItem(STORAGE_KEY)
|
||||||
|
const queryUrl = cachedUrl || currentUrl
|
||||||
|
|
||||||
|
// 查询岗位信息
|
||||||
|
findJobBySourceUrl(queryUrl).then((data) => {
|
||||||
console.log("[OfferPie] 岗位信息:", data)
|
console.log("[OfferPie] 岗位信息:", data)
|
||||||
if (data && data.id) {
|
if (data && data.id) {
|
||||||
setJobInfo(data)
|
setJobInfo(data)
|
||||||
|
// 查到岗位后缓存当前查询成功的 URL
|
||||||
|
sessionStorage.setItem(STORAGE_KEY, queryUrl)
|
||||||
|
// 自动打开面板
|
||||||
if (!autoOpenedRef.current) {
|
if (!autoOpenedRef.current) {
|
||||||
autoOpenedRef.current = true
|
autoOpenedRef.current = true
|
||||||
setVisible(true)
|
setVisible(true)
|
||||||
}
|
}
|
||||||
|
} else if (!cachedUrl) {
|
||||||
|
// 当前 URL 和缓存都没查到,不自动打开
|
||||||
|
console.log("[OfferPie] 当前页面未匹配到岗位信息")
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.warn("[OfferPie] 查询岗位信息失败:", err)
|
console.warn("[OfferPie] 查询岗位信息失败:", err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 如果有缓存 URL 且当前 URL 不同(跳转到了表单页),也自动打开面板
|
||||||
|
if (cachedUrl && !autoOpenedRef.current) {
|
||||||
|
autoOpenedRef.current = true
|
||||||
|
setVisible(true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user