feat: 自定义主角称呼(profile.name + {name} 占位符 + 自报句式预填 + 报告/分享卡展示)
This commit is contained in:
@@ -5,16 +5,18 @@ import type { DimensionScore } from './ReportPage';
|
||||
interface Props {
|
||||
badgeDimension: string;
|
||||
scores: DimensionScore[];
|
||||
/** 玩家自取称呼(C1-01 profile.name),空串时只显示编号 */
|
||||
playerName?: string;
|
||||
}
|
||||
|
||||
/** 分享卡:canvas 生成 PNG 下载(勋章 + 7 维分数) */
|
||||
export function ShareCard({ badgeDimension, scores }: Props) {
|
||||
export function ShareCard({ badgeDimension, scores, playerName }: Props) {
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
draw();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [scores, badgeDimension]);
|
||||
}, [scores, badgeDimension, playerName]);
|
||||
|
||||
function draw(): HTMLCanvasElement {
|
||||
const canvas = canvasRef.current!;
|
||||
@@ -38,6 +40,8 @@ export function ShareCard({ badgeDimension, scores }: Props) {
|
||||
ctx.fillStyle = '#c9b48a';
|
||||
ctx.font = '28px serif';
|
||||
ctx.fillText('苍梧疑冢 · 人格画像', W / 2, 80);
|
||||
ctx.font = '22px serif';
|
||||
ctx.fillText(`C-2049${playerName ? `「${playerName}」` : ''}的档案`, W / 2, 118);
|
||||
|
||||
// 勋章圆
|
||||
ctx.beginPath();
|
||||
|
||||
Reference in New Issue
Block a user