From 89e7bdbed6a2d71703470677c924759570fd341c Mon Sep 17 00:00:00 2001 From: kdletters Date: Thu, 30 Apr 2026 17:23:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5=E9=A1=B6=E9=83=A8?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=A4=B4=E5=83=8F=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...TAB_PROFILE_EDIT_AND_AVATAR_CROP_2026-04-29.md | 1 + .../rpg-entry/RpgEntryHomeView.recharge.test.tsx | 15 +++++++++++++++ src/components/rpg-entry/RpgEntryHomeView.tsx | 12 ++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/technical/MY_TAB_PROFILE_EDIT_AND_AVATAR_CROP_2026-04-29.md b/docs/technical/MY_TAB_PROFILE_EDIT_AND_AVATAR_CROP_2026-04-29.md index 54fe7c0a..88be7bd0 100644 --- a/docs/technical/MY_TAB_PROFILE_EDIT_AND_AVATAR_CROP_2026-04-29.md +++ b/docs/technical/MY_TAB_PROFILE_EDIT_AND_AVATAR_CROP_2026-04-29.md @@ -87,3 +87,4 @@ SpacetimeDB 正式表 `user_account` 需要增加 `avatar_url: Option` 4. 昵称编辑成功后,资料卡与顶部账号入口同步新昵称。 5. 非法头像文件不会进入裁剪流程。 6. 裁剪保存成功后,资料卡头像展示裁剪后的图片。 +7. 桌面右上角账号入口与“我的”资料卡共用 `avatarUrl`,有已保存头像时展示头像图片,缺失时才回退到首字头像。 diff --git a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx index 269e1de0..e0adbcdc 100644 --- a/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx +++ b/src/components/rpg-entry/RpgEntryHomeView.recharge.test.tsx @@ -5,6 +5,7 @@ import userEvent from '@testing-library/user-event'; import { useState } from 'react'; import { afterEach, expect, test, vi } from 'vitest'; +import type { AuthUser } from '../../services/authService'; import { AuthUiContext } from '../auth/AuthUiContext'; import { RpgEntryHomeView, @@ -219,6 +220,7 @@ function renderProfileView( profileDashboardOverrides: Partial< NonNullable > = {}, + userOverrides: Partial = {}, ) { return render( { expect(within(playTimeCard).queryByText('90分')).toBeNull(); }); +test('desktop account entry uses saved avatar image when available', () => { + mockDesktopLayout(); + const avatarUrl = 'data:image/png;base64,AAAA'; + + renderProfileView(vi.fn(), {}, { avatarUrl }); + + const accountEntry = screen.getByRole('button', { name: /测试玩家/u }); + const avatarImage = accountEntry.querySelector('img'); + expect(avatarImage?.getAttribute('src')).toBe(avatarUrl); + expect(within(accountEntry).queryByText('测')).toBeNull(); +}); + test('wallet ledger modal shows empty and error states', async () => { const user = userEvent.setup(); mockGetRpgProfileWalletLedger.mockResolvedValueOnce({ entries: [] }); diff --git a/src/components/rpg-entry/RpgEntryHomeView.tsx b/src/components/rpg-entry/RpgEntryHomeView.tsx index acb69e50..47214dfc 100644 --- a/src/components/rpg-entry/RpgEntryHomeView.tsx +++ b/src/components/rpg-entry/RpgEntryHomeView.tsx @@ -3575,13 +3575,21 @@ export function RpgEntryHomeView({ className="platform-desktop-search flex items-center gap-3 px-3 py-2.5 text-left" > - {avatarLabel} + {avatarUrl ? ( + + ) : ( + avatarLabel + )}