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 + )}