Spaces:
Sleeping
Sleeping
Download src/components/JobCard.jsx from tryprogram/offer-puplayer: direct link, hf CLI and curl.
- Browser
- Download file 7.34 kB
-
https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/src/components/JobCard.jsx
- Command line
-
hf download hf://spaces/tryprogram/offer-puplayer/src/components/JobCard.jsx
-
curl -L -o JobCard.jsx https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/src/components/JobCard.jsx
7.34 kB
| import { useState, useEffect } from 'react' | |
| const RADIUS = 40 | |
| const CIRCUMFERENCE = 2 * Math.PI * RADIUS | |
| function MatchRing({ rate }) { | |
| const [small, setSmall] = useState(window.innerWidth <= 767) | |
| useEffect(() => { | |
| const mq = window.matchMedia('(max-width: 767px)') | |
| const handler = (e) => setSmall(e.matches) | |
| mq.addEventListener('change', handler) | |
| return () => mq.removeEventListener('change', handler) | |
| }, []) | |
| const size = small ? 64 : 96 | |
| const colorVar = rate >= 80 ? 'var(--color-success)' : rate >= 60 ? 'var(--color-warning)' : 'var(--color-error)' | |
| const offset = CIRCUMFERENCE * (1 - rate / 100) | |
| return ( | |
| <svg width={size} height={size} viewBox="0 0 96 96"> | |
| <circle cx="48" cy="48" r={RADIUS} fill="none" stroke="var(--color-border)" strokeWidth="8" /> | |
| <circle | |
| cx="48" cy="48" r={RADIUS} | |
| fill="none" | |
| stroke={colorVar} | |
| strokeWidth="8" | |
| strokeDasharray={CIRCUMFERENCE} | |
| strokeDashoffset={offset} | |
| strokeLinecap="round" | |
| transform="rotate(-90 48 48)" | |
| style={{ transition: 'stroke-dashoffset 0.6s ease' }} | |
| /> | |
| <text | |
| x="48" y="48" | |
| textAnchor="middle" | |
| dominantBaseline="central" | |
| fontSize="20" | |
| fontWeight="700" | |
| fill={colorVar} | |
| > | |
| {rate}% | |
| </text> | |
| </svg> | |
| ) | |
| } | |
| function MatchBreakdown({ detail, rate }) { | |
| if (!detail) return null | |
| const bars = [ | |
| { key: 'semantic', label: '语义匹配', weight: 40, color: 'var(--color-primary-light)' }, | |
| { key: 'tags', label: '技能匹配', weight: 35, color: 'var(--color-success)' }, | |
| { key: 'education', label: '学历匹配', weight: 25, color: 'var(--color-warning)' }, | |
| ] | |
| const rateClass = rate >= 80 ? 'text-success' : rate >= 60 ? 'text-warning' : 'text-error' | |
| return ( | |
| <div className="mt-16 px-16 py-12 info-box"> | |
| <div className="flex-between mb-8"> | |
| <h4 className="font-bold text-sm">匹配度计算</h4> | |
| <span className="text-xs text-light">总分 = 语义×40% + 技能×35% + 学历×25%</span> | |
| </div> | |
| {bars.map(b => { | |
| const val = detail[b.key] || 0 | |
| const pct = Math.round(val * 100) | |
| return ( | |
| <div key={b.key} className="flex items-center gap-8 mb-8"> | |
| <span className="bar-label">{b.label}</span> | |
| <div className="flex-1 progress-bar-md progress-bar-bg-md"> | |
| <div className="progress-bar-fill" style={{ width: pct + '%', backgroundColor: b.color }} /> | |
| </div> | |
| <span className="bar-value" style={{ color: b.color }}>{pct}%</span> | |
| <span className="bar-weight">×{b.weight}%</span> | |
| </div> | |
| ) | |
| })} | |
| <div className="flex-between bar-divider"> | |
| <span className="text-sm font-bold">最终匹配度</span> | |
| <span className={`text-sm font-bold ${rateClass}`}>{rate}%</span> | |
| </div> | |
| </div> | |
| ) | |
| } | |
| function ExpectationSignals({ signals }) { | |
| if (!signals || signals.length === 0) return null | |
| return ( | |
| <div className="mt-12"> | |
| <h4 className="font-bold text-sm mb-8">岗位画像</h4> | |
| <div className="flex flex-wrap gap-8"> | |
| {signals.map((signal, i) => ( | |
| <div key={i} className="signal-tag"> | |
| <span className="signal-tag-name">{signal.name || signal.tag}</span> | |
| {signal.evidence && ( | |
| <span className="signal-tag-evidence">{signal.evidence}</span> | |
| )} | |
| {signal.confidence !== undefined && ( | |
| <div className="flex items-center gap-4"> | |
| <span className="text-xs text-light">置信度</span> | |
| <div className="flex-1 progress-bar-sm progress-bar-bg-sm"> | |
| <div className="progress-bar-fill" style={{ width: `${Math.round(signal.confidence * 100)}%`, backgroundColor: 'var(--color-primary-light)' }} /> | |
| </div> | |
| <span className="text-xs font-bold text-primary"> | |
| {Math.round(signal.confidence * 100)}% | |
| </span> | |
| </div> | |
| )} | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| ) | |
| } | |
| function JobCard({ job, onClick, lowMatchWarning, showMatch = true, onUploadClick }) { | |
| const { job_id, name: title, company, city, match_rate, match_detail, tags = [], description, requirements, expectation_signals } = job | |
| const [expanded, setExpanded] = useState(false) | |
| const visibleTags = tags.slice(0, 3) | |
| const extraCount = tags.length - 3 | |
| const descSummary = description && description.length > 80 | |
| ? description.slice(0, 80) + '...' | |
| : description | |
| return ( | |
| <div className="card"> | |
| <div className="cursor-pointer" onClick={() => setExpanded(!expanded)}> | |
| <div className="flex gap-16 items-center flex-col-mobile gap-mobile-8"> | |
| {showMatch && ( | |
| <div className="flex-shrink-0"> | |
| <MatchRing rate={match_rate} /> | |
| </div> | |
| )} | |
| <div className="flex-1 min-width-0"> | |
| <h3 className="font-bold text-lg">{title}</h3> | |
| <p className="text-secondary mt-8">{company}</p> | |
| <div className="flex flex-wrap gap-8 mt-12"> | |
| <span className="text-sm text-secondary">{city}</span> | |
| {visibleTags.map((tag, i) => ( | |
| <span key={i} className="tag">{tag}</span> | |
| ))} | |
| {extraCount > 0 && ( | |
| <span className="text-sm text-light">+{extraCount}</span> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| {showMatch && lowMatchWarning && ( | |
| <div className="text-sm text-warning mt-12"> | |
| {match_rate < 60 ? '匹配度较低,别灰心,看看建议提升一下吧' : '匹配度较低'} | |
| </div> | |
| )} | |
| {descSummary && ( | |
| <p className="text-sm text-secondary mt-12 leading-normal">{descSummary}</p> | |
| )} | |
| </div> | |
| {expanded && ( | |
| <div className="p-16 mt-12 info-box"> | |
| {description && ( | |
| <div className="mb-12"> | |
| <h4 className="font-bold text-sm mb-4">职位描述</h4> | |
| <p className="text-sm text-secondary">{description}</p> | |
| </div> | |
| )} | |
| {requirements && ( | |
| <div className="mb-12"> | |
| <h4 className="font-bold text-sm mb-4">职位要求</h4> | |
| <p className="text-sm text-secondary">{requirements}</p> | |
| </div> | |
| )} | |
| {showMatch && match_detail && <MatchBreakdown detail={match_detail} rate={match_rate} />} | |
| <ExpectationSignals signals={expectation_signals} /> | |
| <div className="mt-12 flex-center gap-8"> | |
| {showMatch ? ( | |
| <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onClick && onClick(job_id, { job_id, name: title, company, city, match_rate, tags, description, requirements, expectation_signals }) }}> | |
| 查看匹配诊断 | |
| </button> | |
| ) : ( | |
| <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onUploadClick && onUploadClick() }}> | |
| 上传简历后使用匹配 | |
| </button> | |
| )} | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| ) | |
| } | |
| export default JobCard | |