tryprogram's picture
Upload 46 files
61fd574 verified
Raw History Blame Contribute Delete
7.82 kB
import { useState } from 'react'
const RADIUS = 40
const CIRCUMFERENCE = 2 * Math.PI * RADIUS
function MatchRing({ rate }) {
const color = rate >= 80 ? '#10B981' : rate >= 60 ? '#F59E0B' : '#EF4444'
const offset = CIRCUMFERENCE * (1 - rate / 100)
return (
<svg width="96" height="96" viewBox="0 0 96 96">
<circle cx="48" cy="48" r={RADIUS} fill="none" stroke="#E5E7EB" strokeWidth="8" />
<circle
cx="48" cy="48" r={RADIUS}
fill="none"
stroke={color}
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={color}
>
{rate}%
</text>
</svg>
)
}
function MatchBreakdown({ detail, rate }) {
if (!detail) return null
const bars = [
{ key: 'semantic', label: '语义匹配', weight: 40, color: '#6366F1' },
{ key: 'tags', label: '技能匹配', weight: 35, color: '#10B981' },
{ key: 'education', label: '学历匹配', weight: 25, color: '#F59E0B' },
]
return (
<div className="mt-16" style={{ padding: '12px 16px', backgroundColor: '#FFFFFF', borderRadius: 'var(--radius-sm)', border: '1px solid #E5E7EB' }}>
<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-6">
<span className="text-xs" style={{ width: 56, flexShrink: 0 }}>{b.label}</span>
<div style={{ flex: 1, height: 8, backgroundColor: '#F3F4F6', borderRadius: 4, overflow: 'hidden' }}>
<div style={{ width: pct + '%', height: '100%', backgroundColor: b.color, borderRadius: 4, transition: 'width 0.5s ease' }} />
</div>
<span className="text-xs font-bold" style={{ width: 32, textAlign: 'right', color: b.color }}>{pct}%</span>
<span className="text-xs text-light" style={{ width: 28, textAlign: 'right' }}>×{b.weight}%</span>
</div>
)
})}
<div className="flex-between mt-8" style={{ borderTop: '1px solid #E5E7EB', paddingTop: 8 }}>
<span className="text-sm font-bold">最终匹配度</span>
<span className="text-sm font-bold" style={{ color: rate >= 80 ? '#10B981' : rate >= 60 ? '#F59E0B' : '#EF4444' }}>{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="tag" style={{
display: 'flex', flexDirection: 'column', gap: 4,
padding: '8px 12px', backgroundColor: '#EEF2FF',
border: '1px solid #C7D2FE', borderRadius: 'var(--radius-sm)'
}}>
<span className="text-sm font-bold" style={{ color: '#4338CA' }}>{signal.name || signal.tag}</span>
{signal.evidence && (
<span className="text-xs text-secondary">{signal.evidence}</span>
)}
{signal.confidence !== undefined && (
<div className="flex items-center gap-4">
<span className="text-xs text-light">置信度</span>
<div style={{
flex: 1, height: 6, backgroundColor: '#E5E7EB',
borderRadius: 3, overflow: 'hidden'
}}>
<div style={{
width: `${Math.round(signal.confidence * 100)}%`,
height: '100%', backgroundColor: '#6366F1',
borderRadius: 3, transition: 'width 0.4s ease'
}} />
</div>
<span className="text-xs font-bold" style={{ color: '#4338CA' }}>
{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 style={{ cursor: 'pointer' }} onClick={() => setExpanded(!expanded)}>
<div className="gap-16" style={{ display: 'flex', alignItems: 'center' }}>
{showMatch && (
<div style={{ flexShrink: 0 }}>
<MatchRing rate={match_rate} />
</div>
)}
<div style={{ flex: 1, minWidth: 0 }}>
<h3 className="font-bold text-lg">{title}</h3>
<p className="text-secondary mt-8">{company}</p>
<div className="flex flex-wrap gap-8" style={{ marginTop: 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" style={{ marginTop: 12 }}>
{match_rate < 60 ? '匹配度较低,别灰心,看看建议提升一下吧' : '匹配度较低'}
</div>
)}
{descSummary && (
<p className="text-sm text-secondary mt-12" style={{ lineHeight: 1.5 }}>{descSummary}</p>
)}
</div>
{expanded && (
<div style={{ marginTop: 12, padding: 16, backgroundColor: '#F9FAFB', borderRadius: 'var(--radius-sm)' }}>
{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 gap-8" style={{ justifyContent: 'center' }}>
{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