feat: 自定义主角称呼(profile.name + {name} 占位符 + 自报句式预填 + 报告/分享卡展示)

This commit is contained in:
Jayway Liu
2026-10-03 22:13:31 +08:00
parent 316cdfaffe
commit 512651b973
9 changed files with 94 additions and 22 deletions
+6 -1
View File
@@ -43,11 +43,15 @@ export function ReportPage({ store, jev, onReplay }: Props) {
const [scores, setScores] = useState<DimensionScore[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [retry, setRetry] = useState(0);
const [playerName, setPlayerName] = useState('');
useEffect(() => {
let cancelled = false;
(async () => {
const events = await store.list();
// 最近一次身份登记的称呼(旧数据缺 name 字段时回退空串 → 只显示编号)
const name = [...events].reverse().find((e) => e.kind === 'profile')?.profile?.name ?? '';
if (!cancelled) setPlayerName(name);
const state = buildState(events);
// 7 维 score 问题,criteria 为 10 级有序数组(索引 0-9 对应 1-10 级)
const criteria = Array.from({ length: 10 }, (_, i) => `${i + 1} 级`);
@@ -120,6 +124,7 @@ export function ReportPage({ store, jev, onReplay }: Props) {
return (
<div className="report">
<h1>人格画像报告 · Act 1</h1>
<p className="hint">C-2049{playerName ? `「${playerName}」` : ''}的档案</p>
<section className="badge-banner">
<div className="badge-medal">勋</div>
<div>
@@ -143,7 +148,7 @@ export function ReportPage({ store, jev, onReplay }: Props) {
</div>
))}
</section>
<ShareCard badgeDimension={top.id} scores={scores} />
<ShareCard badgeDimension={top.id} scores={scores} playerName={playerName} />
<button className="secondary" onClick={onReplay}>
重玩 Act 1(新轨迹,历史保留)
</button>