feat: 完善中文心理测评平台

This commit is contained in:
mikemoi
2026-06-22 22:59:01 +02:00
commit 9227c687fc
160 changed files with 16974 additions and 0 deletions
@@ -0,0 +1,79 @@
'use client';
import {
calculateRIASECResults,
riasecTypes,
} from '../../test/private/RIASECCalculator';
interface RIASECResultProps {
answers: string[];
}
const descriptions = {
R: '动手、设备、机械、户外与具体操作',
I: '研究、分析、科学与复杂问题',
A: '创作、设计、表达与开放式任务',
S: '帮助、教学、照护与合作',
E: '领导、说服、销售与组织资源',
C: '数据、记录、流程与明确规范',
};
function barWidth(average: number) {
return `${Math.max(0, Math.min(100, ((average - 1) / 4) * 100))}%`;
}
export function RIASECResult({ answers }: RIASECResultProps) {
const { scores, ranking, hollandCode } = calculateRIASECResults(answers);
return (
<div className="mt-6 space-y-6">
<div className="border bg-white p-6 shadow-sm">
<div className="text-sm text-muted-foreground"> Holland Code</div>
<div className="mt-1 text-4xl font-semibold text-indigo-600">
{hollandCode}
</div>
<p className="mt-3 text-sm text-muted-foreground">
</p>
</div>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
{ranking.map(([code]) => {
const result = scores[code] as { score: number; average: number };
const type = riasecTypes[code as keyof typeof riasecTypes];
return (
<div key={code} className="rounded-lg border bg-white p-5 shadow-sm">
<div className="flex items-start justify-between gap-4">
<div>
<h4 className="font-semibold">
{code} · {type.name}
</h4>
<p className="mt-1 text-sm text-muted-foreground">
{descriptions[code as keyof typeof descriptions]}
</p>
</div>
<div className="shrink-0 text-right">
<div className="text-xl font-semibold">{result.score}</div>
<div className="text-xs text-muted-foreground">/ 40</div>
</div>
</div>
<div className="mt-4 h-2 overflow-hidden rounded-full bg-gray-100">
<div
className="h-full rounded-full bg-emerald-500"
style={{ width: barWidth(result.average) }}
/>
</div>
<div className="mt-2 text-xs text-muted-foreground">
{result.average.toFixed(2)} / 5
</div>
</div>
);
})}
</div>
<div className="border bg-gray-50 p-4 text-sm text-gray-700">
</div>
</div>
);
}