From e4f846c2cb6ea57e60257de72edf4ebce3fb2ae6 Mon Sep 17 00:00:00 2001 From: lingyunxsh Date: Tue, 25 Aug 2026 19:51:00 +0800 Subject: [PATCH] init --- client/browser/applicant.py | 21 +++++++++++++++------ client/web/static/app.js | 10 +++++++++- client/web/templates/index.html | 1 + server/models.py | 4 ++++ server/routers/jobs.py | 6 ++++++ server/schemas.py | 4 ++++ 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/client/browser/applicant.py b/client/browser/applicant.py index 7c3e646..44ec660 100644 --- a/client/browser/applicant.py +++ b/client/browser/applicant.py @@ -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 diff --git a/client/web/static/app.js b/client/web/static/app.js index 6dc896b..ba61ee5 100644 --- a/client/web/static/app.js +++ b/client/web/static/app.js @@ -354,7 +354,7 @@ async function loadHistory() { `; $('historyBody').innerHTML = history.map(h => ` - ${escapeHtml(h.job_title || '-')} + ${escapeHtml(h.job_title || '-')} ${escapeHtml(h.company || '-')} ${escapeHtml(h.salary || '-')} ${typeLabel(h.apply_type)} @@ -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'; diff --git a/client/web/templates/index.html b/client/web/templates/index.html index 144b81c..018a640 100644 --- a/client/web/templates/index.html +++ b/client/web/templates/index.html @@ -134,6 +134,7 @@