Spaces:
Sleeping
Sleeping
Download frontend/src/pages/SuggestPage.jsx from tryprogram/offer-puplayer: direct link, hf CLI and curl.
- Browser
- Download file 6.53 kB
-
https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/frontend/src/pages/SuggestPage.jsx
- Command line
-
hf download hf://spaces/tryprogram/offer-puplayer/frontend/src/pages/SuggestPage.jsx
-
curl -L -o SuggestPage.jsx https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/frontend/src/pages/SuggestPage.jsx
6.53 kB
| import { useState, useCallback } from 'react' | |
| import { rerankReport } from '../api' | |
| function SuggestPage({ jobId, resumeData, advice, onBack }) { | |
| const defaultSkills = 'Python, Java, SQL, PyTorch, Flask' | |
| const defaultProjects = '推荐系统, 电商后端' | |
| const defaultExp = '6个月实习经历,参与推荐系统数据管道维护' | |
| const initData = resumeData || {} | |
| const projToString = (p) => typeof p === 'string' ? p : (p.name || p.title || '') | |
| const [editedResume, setEditedResume] = useState({ | |
| skills: (initData.skills || []).join(', ') || defaultSkills, | |
| projects: (initData.projects || []).map(projToString).join(', ') || defaultProjects, | |
| experience: initData.experience || defaultExp | |
| }) | |
| const [rerankResult, setRerankResult] = useState(null) | |
| const [reranking, setReranking] = useState(false) | |
| const handleRerank = useCallback(async () => { | |
| const hasContent = editedResume.skills.trim() || editedResume.projects.trim() || editedResume.experience.trim() | |
| if (!hasContent) return | |
| setReranking(true) | |
| try { | |
| const text = `技能: ${editedResume.skills}\n项目: ${editedResume.projects}\n经历: ${editedResume.experience}` | |
| const res = await rerankReport(jobId, text) | |
| setRerankResult(res.data) | |
| } catch { | |
| setRerankResult({ error: '重评估失败' }) | |
| } | |
| setReranking(false) | |
| }, [jobId, editedResume]) | |
| return ( | |
| <div> | |
| <h2 className="font-bold text-xl mb-24">简历修改建议</h2> | |
| {advice && ( | |
| <> | |
| {advice.rewrite_suggestions && advice.rewrite_suggestions.length > 0 && ( | |
| <div className="mb-24"> | |
| <h3 className="font-bold mb-16">📝 简历修改建议</h3> | |
| <div className="flex flex-col gap-16"> | |
| {advice.rewrite_suggestions.map((item, i) => ( | |
| <div key={i} className="card"> | |
| <div className="flex-between mb-8"> | |
| <span className="font-bold">{item.dimension}</span> | |
| <span className="text-sm text-warning">{item.issue}</span> | |
| </div> | |
| <div className="mb-8"> | |
| <span className="text-sm text-secondary">原文: </span> | |
| <span className="text-sm" style={{ textDecoration: 'line-through', color: '#EF4444' }}>{item.original}</span> | |
| </div> | |
| <div className="mb-8"> | |
| <span className="text-sm text-secondary">建议: </span> | |
| <span className="text-sm font-bold" style={{ color: '#10B981' }}>{item.suggestion}</span> | |
| </div> | |
| <div> | |
| <span className="text-sm text-light">{item.reason}</span> | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| {advice.interview_tips && advice.interview_tips.length > 0 && ( | |
| <div className="mb-24"> | |
| <h3 className="font-bold mb-16">🎯 面试准备方向</h3> | |
| <div className="flex flex-col gap-16"> | |
| {advice.interview_tips.map((item, i) => ( | |
| <div key={i} className="card"> | |
| <div className="flex-between mb-8"> | |
| <span className="font-bold">{item.topic}</span> | |
| <span className="text-sm text-secondary">{item.reason}</span> | |
| </div> | |
| <p className="text-sm" style={{ color: '#4F46E5' }}>{item.tip}</p> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| {advice.encouragement && ( | |
| <div className="card mb-24" style={{ backgroundColor: 'rgba(16,185,129,0.06)', borderColor: '#10B981' }}> | |
| <h3 className="font-bold mb-8">💪 鼓励</h3> | |
| <p className="text-secondary">{advice.encouragement}</p> | |
| </div> | |
| )} | |
| <hr className="divider mb-24" /> | |
| </> | |
| )} | |
| <div className="card mb-24"> | |
| <h3 className="font-bold mb-16">编辑简历</h3> | |
| <div className="flex flex-col gap-12"> | |
| <div> | |
| <label className="text-sm font-bold">技能(逗号分隔)</label> | |
| <input | |
| className="input" | |
| value={editedResume.skills} | |
| onChange={e => setEditedResume(p => ({ ...p, skills: e.target.value }))} | |
| placeholder="如: React, Python, SQL" | |
| /> | |
| </div> | |
| <div> | |
| <label className="text-sm font-bold">项目经历</label> | |
| <textarea | |
| className="input" | |
| rows={3} | |
| value={editedResume.projects} | |
| onChange={e => setEditedResume(p => ({ ...p, projects: e.target.value }))} | |
| placeholder="描述你的项目经历" | |
| /> | |
| </div> | |
| <div> | |
| <label className="text-sm font-bold">实习经历</label> | |
| <textarea | |
| className="input" | |
| rows={3} | |
| value={editedResume.experience} | |
| onChange={e => setEditedResume(p => ({ ...p, experience: e.target.value }))} | |
| placeholder="描述你的实习经历" | |
| /> | |
| </div> | |
| </div> | |
| <button className="btn btn-primary mt-16" onClick={handleRerank} disabled={reranking || !(editedResume.skills.trim() || editedResume.projects.trim() || editedResume.experience.trim())}> | |
| {reranking ? '重新评估中...' : '重新评估匹配度'} | |
| </button> | |
| </div> | |
| {rerankResult && !rerankResult.error && ( | |
| <div className="card mb-24"> | |
| <h3 className="font-bold mb-16">修改后匹配度</h3> | |
| <p>匹配度:<span className="font-bold text-lg">{rerankResult.match_rate}%</span></p> | |
| <p className="text-secondary mt-8">修改前:{rerankResult.previous_rate}%</p> | |
| {rerankResult.match_rate > rerankResult.previous_rate && ( | |
| <p className="text-success mt-8">修改有效,匹配度提升了 {rerankResult.match_rate - rerankResult.previous_rate}%</p> | |
| )} | |
| </div> | |
| )} | |
| <div className="text-center"> | |
| <button className="btn btn-secondary" onClick={onBack}>返回诊断</button> | |
| </div> | |
| </div> | |
| ) | |
| } | |
| export default SuggestPage |