fix public work author display

This commit is contained in:
kdletters
2026-05-28 17:47:31 +08:00
parent f1fb92aa29
commit 31afb2b18a
6 changed files with 88 additions and 15 deletions

View File

@@ -15295,6 +15295,7 @@ export function PlatformEntryFlowShellImpl({
<PlatformWorkDetailView
entry={selectedPublicWorkDetail}
authorAvatarUrl={selectedPublicWorkAuthor?.avatarUrl ?? null}
authorUsername={selectedPublicWorkAuthor?.username ?? null}
authorDisplayName={selectedPublicWorkAuthor?.displayName ?? null}
isBusy={
isPublicWorkDetailBusy ||
@@ -15342,6 +15343,7 @@ export function PlatformEntryFlowShellImpl({
<PlatformWorkDetailView
entry={mapRpgGalleryCardToPublicWorkDetail(selectedDetailEntry)}
authorAvatarUrl={selectedPublicWorkAuthor?.avatarUrl ?? null}
authorUsername={selectedPublicWorkAuthor?.username ?? null}
authorDisplayName={
selectedPublicWorkAuthor?.displayName ?? null
}

View File

@@ -9,6 +9,7 @@ import {
EDUTAINMENT_BABY_OBJECT_MATCH_TEMPLATE_NAME,
type PlatformEdutainmentGalleryCard,
type PlatformPuzzleGalleryCard,
type PlatformWoodenFishGalleryCard,
} from '../rpg-entry/rpgEntryWorldPresentation';
import { PlatformWorkDetailView } from './PlatformWorkDetailView';
@@ -82,6 +83,29 @@ function createBabyObjectMatchEntry(): PlatformEdutainmentGalleryCard {
};
}
function createWoodenFishEntry(): PlatformWoodenFishGalleryCard {
return {
sourceType: 'wooden-fish',
workId: 'wooden-fish-work-1',
profileId: 'wooden-fish-profile-1',
publicWorkCode: 'WF-001',
ownerUserId: 'user-wooden-fish',
authorDisplayName: '敲木鱼玩家',
worldName: '莲花木鱼',
subtitle: '敲木鱼',
summaryText: '莲花主题敲木鱼。',
coverImageSrc: null,
themeTags: ['敲木鱼'],
playCount: 12,
remixCount: 0,
likeCount: 4,
recentPlayCount7d: 0,
visibility: 'published',
publishedAt: '2026-05-20T10:00:00.000Z',
updatedAt: '2026-05-20T12:00:00.000Z',
};
}
afterEach(() => {
vi.useRealTimers();
});
@@ -133,6 +157,26 @@ test('PlatformWorkDetailView prefers resolved public user display name', () => {
expect(screen.queryByText('137****6613')).toBeNull();
});
test('PlatformWorkDetailView prefers resolved username for wooden fish works', () => {
render(
<PlatformWorkDetailView
entry={createWoodenFishEntry()}
authorUsername="lotus_user"
authorDisplayName="公开昵称"
isBusy={false}
error={null}
onBack={vi.fn()}
onLike={vi.fn()}
onStart={vi.fn()}
onRemix={vi.fn()}
/>,
);
expect(screen.getByText('lotus_user')).toBeTruthy();
expect(screen.queryByText('敲木鱼玩家')).toBeNull();
expect(screen.queryByText('公开昵称')).toBeNull();
});
test('PlatformWorkDetailView calls like handler', () => {
const onLike = vi.fn();
render(

View File

@@ -25,6 +25,7 @@ import {
isBarkBattleGalleryEntry,
isEdutainmentGalleryEntry,
type PlatformPublicGalleryCard,
resolvePlatformWorkAuthorDisplayName,
resolvePlatformPublicWorkCode,
resolvePlatformWorldCoverSlides,
resolvePlatformWorldStats,
@@ -33,6 +34,7 @@ import {
export interface PlatformWorkDetailViewProps {
entry: PlatformPublicGalleryCard;
authorAvatarUrl?: string | null;
authorUsername?: string | null;
authorDisplayName?: string | null;
isBusy: boolean;
error?: string | null;
@@ -86,6 +88,7 @@ const PLATFORM_WORK_COVER_CAROUSEL_INTERVAL_MS = 4200;
export function PlatformWorkDetailView({
entry,
authorAvatarUrl,
authorUsername,
authorDisplayName,
isBusy,
visibleCoverCount = 1,
@@ -109,8 +112,10 @@ export function PlatformWorkDetailView({
const hasCoverCarousel = coverSlides.length > 1;
const publicWorkCode = resolvePlatformPublicWorkCode(entry);
const normalizedAuthorAvatarUrl = authorAvatarUrl?.trim() ?? '';
const resolvedAuthorDisplayName =
authorDisplayName?.trim() || entry.authorDisplayName;
const resolvedAuthorDisplayName = resolvePlatformWorkAuthorDisplayName(
entry,
authorUsername?.trim() || authorDisplayName?.trim() || null,
);
const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>(
'idle',
);