init
This commit is contained in:
@@ -161,20 +161,25 @@ class Applicant:
|
||||
|
||||
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
||||
|
||||
# 2. AI 匹配度评分
|
||||
# 2. 抓取 JD 详情(供 AI 评分与归档记录,统一前置)
|
||||
if not card.jd_text:
|
||||
card.jd_text = self._fetch_jd_detail(card)
|
||||
|
||||
# 3. AI 匹配度评分
|
||||
ai_score, ai_reason = -1, ""
|
||||
if self.ai and self.ai.available() and self.primary_resume_content:
|
||||
jd = card.jd_text or self._fetch_jd_detail(card)
|
||||
result = self.ai.score_job(jd, self.primary_resume_content)
|
||||
result = self.ai.score_job(card.jd_text, self.primary_resume_content)
|
||||
ai_score, ai_reason = result.score, result.reason
|
||||
if not result.is_worth_applying(min_score):
|
||||
self._report_skip(card, f"AI 评分低({ai_score})", ai_score, ai_reason)
|
||||
return 0
|
||||
|
||||
# 3. 执行投递
|
||||
# 4. 执行投递
|
||||
success, apply_type = self._apply(card, greeting)
|
||||
if success:
|
||||
self._report_apply(card, apply_type, ai_score, ai_reason)
|
||||
# 打招呼语仅 chat 方式实际发送过,才归档
|
||||
greeting_used = greeting if (apply_type == "chat" and greeting) else None
|
||||
self._report_apply(card, apply_type, ai_score, ai_reason, greeting_used)
|
||||
self._sleep(*delay_range)
|
||||
return 1
|
||||
return 0
|
||||
@@ -182,7 +187,8 @@ class Applicant:
|
||||
# ------------------------------------------------------------------
|
||||
# 服务端上报
|
||||
# ------------------------------------------------------------------
|
||||
def _report_apply(self, card: JobCard, apply_type: str, ai_score: int, ai_reason: str):
|
||||
def _report_apply(self, card: JobCard, apply_type: str, ai_score: int, ai_reason: str,
|
||||
greeting: str | None = None):
|
||||
try:
|
||||
self.server.report_application(self.session_id, {
|
||||
"job_id": card.job_id,
|
||||
@@ -193,6 +199,8 @@ class Applicant:
|
||||
"apply_type": apply_type,
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"jd_text": card.jd_text or None,
|
||||
"greeting": greeting,
|
||||
})
|
||||
self.server.update_session_stats(self.session_id, applied_delta=1, skipped_delta=0)
|
||||
self.stats["applied"] += 1
|
||||
@@ -211,6 +219,7 @@ class Applicant:
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"skip_reason": reason,
|
||||
"jd_text": card.jd_text or None,
|
||||
})
|
||||
self.server.update_session_stats(self.session_id, applied_delta=0, skipped_delta=1)
|
||||
self.stats["skipped"] += 1
|
||||
|
||||
@@ -354,7 +354,7 @@ async function loadHistory() {
|
||||
`;
|
||||
$('historyBody').innerHTML = history.map(h => `
|
||||
<tr>
|
||||
<td>${escapeHtml(h.job_title || '-')}</td>
|
||||
<td title="${escapeHtml(recordDetail(h))}">${escapeHtml(h.job_title || '-')}</td>
|
||||
<td>${escapeHtml(h.company || '-')}</td>
|
||||
<td>${escapeHtml(h.salary || '-')}</td>
|
||||
<td><span class="tag ${safeType(h.apply_type)}">${typeLabel(h.apply_type)}</span></td>
|
||||
@@ -368,6 +368,14 @@ async function loadHistory() {
|
||||
function typeLabel(t) {
|
||||
return { chat: '沟通', deliver: '投递', skipped: '跳过' }[t] || t;
|
||||
}
|
||||
// 悬停详情:JD 摘要 + 打招呼语(用于 title 属性)
|
||||
function recordDetail(h) {
|
||||
const parts = [];
|
||||
if (h.greeting) parts.push(`【打招呼语】${h.greeting}`);
|
||||
if (h.jd_text) parts.push(`【JD】${h.jd_text.substring(0, 300)}${h.jd_text.length > 300 ? '...' : ''}`);
|
||||
if (h.skip_reason) parts.push(`【跳过原因】${h.skip_reason}`);
|
||||
return parts.join('\n\n') || '暂无详情';
|
||||
}
|
||||
// apply_type 仅允许白名单值用作 CSS class,防止注入
|
||||
function safeType(t) {
|
||||
return ['chat', 'deliver', 'skipped'].includes(t) ? t : 'skipped';
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<!-- Step 5: 投递记录 -->
|
||||
<section class="panel hidden" id="panel-5">
|
||||
<h2>投递记录与统计</h2>
|
||||
<p class="hint">将鼠标悬停在职位名上,可查看归档的 JD 摘要、打招呼语与跳过原因。</p>
|
||||
<div class="stats-grid" id="statsGrid"></div>
|
||||
<table class="history-table">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user