fix(huya): 优化兑换结果图字段与布局

This commit is contained in:
yml
2026-11-13 21:41:54 +08:00
parent 7f49bc8579
commit 269a8d1b11
2 changed files with 14 additions and 14 deletions
+3 -3
View File
@@ -661,14 +661,14 @@ export default function HuyaElitePage() {
)
? recordsTask.result.account_snapshot as Record<string, unknown>
: {};
const account = accounts.find((item) => item.id === recordsTask?.account_id);
const recordKey = String(record.record_id || record.order_id || index);
return {
key: `huya:${recordsTask?.id || 'records'}:${recordKey}`,
goodsName: String(record.prize_name || '未知商品'),
goodsPic: String(record.icon || ''),
roleName: String(snapshot.game_name || ''),
channel: String(snapshot.game_channel || ''),
accountName: String(snapshot.uid || recordsTask?.account_uid || snapshot.nickname || recordsTask?.account_nickname || '-'),
roleName: String(snapshot.game_name || account?.game_name || ''),
channel: String(snapshot.game_channel || account?.game_channel || ''),
exchangeTime: String(record.exchange_time_text || ''),
statusText: String(record.status_label || '兑换成功'),
footerText: '虎牙精英宝典兑换记录凭证 · 数据来自官方兑换记录',
+11 -11
View File
@@ -17,7 +17,7 @@ export interface ExchangeResultImageData {
goodsPic?: string;
roleName?: string;
channel?: string;
accountName: string;
accountName?: string;
exchangeTime?: string;
statusText?: string;
footerText?: string;
@@ -150,11 +150,11 @@ export async function drawExchangeResultImage(
ctx.textBaseline = 'middle';
ctx.fillStyle = '#ffffff';
ctx.font = `bold 28px ${FONT_FAMILY}`;
ctx.fillText('兑 换 成 功', CARD_W / 2, 56);
ctx.fillText('兑 换 成 功', CARD_W / 2, 46);
// 商品图(圆形裁剪)
const avatarR = 52;
const avatarY = 112;
const avatarY = 128;
ctx.save();
ctx.beginPath();
ctx.arc(CARD_W / 2, avatarY, avatarR, 0, Math.PI * 2);
@@ -201,25 +201,25 @@ export async function drawExchangeResultImage(
ctx.strokeStyle = 'rgba(255,255,255,0.18)';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(32, 260);
ctx.lineTo(CARD_W - 32, 260);
ctx.moveTo(32, 268);
ctx.lineTo(CARD_W - 32, 268);
ctx.stroke();
// 信息区
const infoRows: Array<[string, string]> = [];
if (info.roleName) infoRows.push(['游戏角色', info.roleName]);
if (info.channel) infoRows.push(['游戏区服', info.channel]);
infoRows.push(['兑换账号', info.accountName]);
if (info.accountName) infoRows.push(['兑换账号', info.accountName]);
if (time) infoRows.push(['兑换时间', time]);
ctx.font = `15px ${FONT_FAMILY}`;
let rowY = 288;
let rowY = 296;
for (const [label, value] of infoRows) {
ctx.textAlign = 'left';
ctx.fillStyle = 'rgba(255,255,255,0.6)';
ctx.fillText(label, 36, rowY);
ctx.fillStyle = '#ffffff';
ctx.fillText(truncate(value, 16), 128, rowY);
ctx.fillText(truncate(value, label === '兑换时间' ? 22 : 16), 128, rowY);
rowY += 27;
}
@@ -229,18 +229,18 @@ export async function drawExchangeResultImage(
const badgeW = ctx.measureText(badgeText).width + 34;
const badgeX = (CARD_W - badgeW) / 2;
ctx.fillStyle = '#2bb673';
roundRect(ctx, badgeX, 428, badgeW, 32, 16);
roundRect(ctx, badgeX, 410, badgeW, 32, 16);
ctx.fill();
ctx.fillStyle = '#ffffff';
ctx.textAlign = 'center';
ctx.fillText(badgeText, CARD_W / 2, 444);
ctx.fillText(badgeText, CARD_W / 2, 426);
ctx.fillStyle = 'rgba(255,255,255,0.35)';
ctx.font = `10px ${FONT_FAMILY}`;
ctx.fillText(
data.footerText || '真实兑换记录凭证 · 仅用于订单核验',
CARD_W / 2,
CARD_H - 12,
CARD_H - 8,
);
return new Promise<Blob>((resolve, reject) => {