From 269a8d1b11196bb77a688aca7f540939b43bf8fe Mon Sep 17 00:00:00 2001 From: yml Date: Fri, 13 Nov 2026 21:41:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(huya):=20=E4=BC=98=E5=8C=96=E5=85=91?= =?UTF-8?q?=E6=8D=A2=E7=BB=93=E6=9E=9C=E5=9B=BE=E5=AD=97=E6=AE=B5=E4=B8=8E?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/frontend/src/pages/HuyaElitePage.tsx | 6 +++--- web/frontend/src/utils/exchangeImage.ts | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/web/frontend/src/pages/HuyaElitePage.tsx b/web/frontend/src/pages/HuyaElitePage.tsx index 01eff87..26b19b7 100644 --- a/web/frontend/src/pages/HuyaElitePage.tsx +++ b/web/frontend/src/pages/HuyaElitePage.tsx @@ -661,14 +661,14 @@ export default function HuyaElitePage() { ) ? recordsTask.result.account_snapshot as Record : {}; + 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: '虎牙精英宝典兑换记录凭证 · 数据来自官方兑换记录', diff --git a/web/frontend/src/utils/exchangeImage.ts b/web/frontend/src/utils/exchangeImage.ts index decf7be..b5da712 100644 --- a/web/frontend/src/utils/exchangeImage.ts +++ b/web/frontend/src/utils/exchangeImage.ts @@ -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((resolve, reject) => {