收口公开编号搜索结果弹层

平台入口公开编号搜索结果弹层改用 UnifiedModal 承接公共模态外壳
未命中提示与命中用户卡分别复用 PlatformStatusMessage 和 PlatformSubpanel
补充公开编号搜索结果弹层交互测试与收口文档记录
This commit is contained in:
2026-06-10 15:26:22 +08:00
parent fface53745
commit 1e6ecf2ea9
4 changed files with 85 additions and 34 deletions

View File

@@ -364,11 +364,13 @@ import {
import type { CustomWorldProfile } from '../../types';
import { useAuthUi } from '../auth/AuthUiContext';
import { PlatformActionButton } from '../common/PlatformActionButton';
import { PlatformModalCloseButton } from '../common/PlatformModalCloseButton';
import { PlatformFieldLabel } from '../common/PlatformFieldLabel';
import { PlatformStatusMessage } from '../common/PlatformStatusMessage';
import { PlatformSubpanel } from '../common/PlatformSubpanel';
import { PublishShareModal } from '../common/PublishShareModal';
import type { PublishShareModalPayload } from '../common/publishShareModalModel';
import { UnifiedConfirmDialog } from '../common/UnifiedConfirmDialog';
import { UnifiedModal } from '../common/UnifiedModal';
import { resolveCreativeAgentTargetSelectionStage } from '../creative-agent/creativeAgentViewModel';
import {
buildCreationWorkShelfItems,
@@ -13942,6 +13944,11 @@ export function PlatformEntryFlowShellImpl({
],
);
const closePublicSearchResult = useCallback(() => {
setSearchedPublicUser(null);
setPublicSearchError(null);
}, []);
const openProfilePlayedWorks = useCallback(() => {
setIsProfilePlayStatsOpen(true);
setIsProfilePlayStatsLoading(true);
@@ -17054,49 +17061,47 @@ export function PlatformEntryFlowShellImpl({
{pendingDeleteCreationWork?.detail}
</UnifiedConfirmDialog>
<AnimatePresence>
{(searchedPublicUser || publicSearchError) && (
{searchedPublicUser || publicSearchError ? (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4"
>
<div className="platform-surface w-full max-w-md rounded-[1.6rem] p-5">
<div className="flex items-start justify-between gap-4">
<div>
<div className="text-sm font-semibold text-[var(--platform-text-soft)]">
</div>
<div className="mt-1 text-xl font-black text-[var(--platform-text-strong)]">
{publicSearchError ? '未找到结果' : '命中用户'}
</div>
</div>
<PlatformModalCloseButton
onClick={() => {
setSearchedPublicUser(null);
setPublicSearchError(null);
}}
label="关闭搜索结果"
variant="platformIcon"
/>
</div>
<UnifiedModal
open
title={publicSearchError ? '未找到结果' : '命中用户'}
description="公开编号搜索"
onClose={closePublicSearchResult}
closeOnBackdrop={false}
closeLabel="关闭搜索结果"
portal={false}
size="sm"
overlayClassName={`platform-theme ${platformThemeClass} !items-center bg-black/45 !p-4`}
panelClassName="platform-remap-surface rounded-[1.6rem]"
>
{publicSearchError ? (
<div className="mt-4 text-sm leading-6 text-[var(--platform-text-soft)]">
<PlatformStatusMessage tone="neutral" surface="platform" size="md">
{publicSearchError}
</div>
</PlatformStatusMessage>
) : searchedPublicUser ? (
<div className="mt-4 rounded-[1.2rem] border border-[var(--platform-line-soft)] p-4">
<div className="text-lg font-bold text-[var(--platform-text-strong)]">
{searchedPublicUser.displayName}
<PlatformSubpanel
as="section"
surface="flat"
radius="sm"
padding="md"
title={searchedPublicUser.displayName}
titleVariant="strong"
bodyClassName="mt-3"
>
<PlatformFieldLabel></PlatformFieldLabel>
<div className="mt-1 text-sm font-semibold text-[var(--platform-text-base)]">
{searchedPublicUser.publicUserCode}
</div>
<div className="mt-2 text-sm text-[var(--platform-text-soft)]">
{searchedPublicUser.publicUserCode}
</div>
</div>
</PlatformSubpanel>
) : null}
</div>
</UnifiedModal>
</motion.div>
)}
) : null}
</AnimatePresence>
</>
);

View File

@@ -7334,11 +7334,53 @@ test('public code search blocks edutainment work when entry switch is disabled',
await user.type(searchInput, 'PZ-TMENT1');
await user.click(screen.getByRole('button', { name: '搜索' }));
expect(await screen.findByText('未找到结果')).toBeTruthy();
const dialog = await screen.findByRole('dialog', { name: '未找到结果' });
expect(within(dialog).getByText('公开编号搜索')).toBeTruthy();
expect(within(dialog).getByText('未找到拼图作品。')).toBeTruthy();
await user.click(
within(dialog).getByRole('button', { name: '关闭搜索结果' }),
);
await waitFor(() => {
expect(screen.queryByRole('dialog', { name: '未找到结果' })).toBeNull();
});
expect(screen.queryByText('儿童动作热身 Demo')).toBeNull();
expect(getPuzzleGalleryDetail).not.toHaveBeenCalled();
});
test('public code search shows public user summary in shared search result modal and clears it on close', async () => {
const user = userEvent.setup();
vi.mocked(authServiceMocks.getPublicAuthUserByCode).mockResolvedValue({
id: 'public-user-yjsh',
publicUserCode: 'SY-00000001',
username: 'author_user',
displayName: '公开作者',
avatarUrl: null,
});
render(<TestWrapper withAuth />);
await openDiscoverHub(user);
const searchInput =
await screen.findByPlaceholderText('搜索作品号、名称、作者、描述');
await user.type(searchInput, '月井守望');
await user.click(screen.getByRole('button', { name: '搜索' }));
const dialog = await screen.findByRole('dialog', { name: '命中用户' });
expect(within(dialog).getByText('公开编号搜索')).toBeTruthy();
expect(within(dialog).getByText('公开作者')).toBeTruthy();
expect(within(dialog).getByText('陶泥号')).toBeTruthy();
expect(within(dialog).getByText('SY-00000001')).toBeTruthy();
await user.click(
within(dialog).getByRole('button', { name: '关闭搜索结果' }),
);
await waitFor(() => {
expect(screen.queryByRole('dialog', { name: '命中用户' })).toBeNull();
});
});
test('creation hub clears all private work shelves immediately after logout state', async () => {
const user = userEvent.setup();
const loggedInAuth = createAuthValue();