fix public work detail not found recovery
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-05-11 19:52:25 +08:00
parent 7cea41c911
commit 54968701f0
7 changed files with 182 additions and 8 deletions

View File

@@ -99,7 +99,10 @@ import {
buildPublicWorkStagePath,
pushAppHistoryPath,
} from '../../routing/appPageRoutes';
import { resolveRuntimeNotFoundRecoveryAction } from '../../routing/runtimeNotFoundRecovery';
import {
resolveRuntimeNotFoundRecoveryAction,
resolveWorkNotFoundRecoveryAction,
} from '../../routing/runtimeNotFoundRecovery';
import {
ApiClientError,
BACKGROUND_AUTH_REQUEST_OPTIONS,
@@ -907,6 +910,24 @@ function maybeAlertRuntimeNotFoundAndReturnHome() {
return true;
}
function maybeAlertWorkNotFoundAndReturnHome() {
if (typeof window === 'undefined') {
return false;
}
const recoveryAction = resolveWorkNotFoundRecoveryAction(
window.location.pathname,
);
if (!recoveryAction) {
return false;
}
// 中文注释:直接打开公开详情或运行态深链失效时,确认提示后必须离开空详情页。
window.alert('作品不存在或已下架,将返回首页。');
pushAppHistoryPath(recoveryAction.nextPath);
return true;
}
function hasSeenPuzzleOnboarding() {
if (typeof window === 'undefined') {
return true;
@@ -4334,7 +4355,7 @@ export function PlatformEntryFlowShellImpl({
setPublicWorkDetailError(null);
setPlatformTab('home');
setSelectionStage('platform');
if (!maybeAlertRuntimeNotFoundAndReturnHome()) {
if (!maybeAlertWorkNotFoundAndReturnHome()) {
pushAppHistoryPath('/');
}
return false;
@@ -5836,7 +5857,7 @@ export function PlatformEntryFlowShellImpl({
setPublicWorkDetailError(null);
setPlatformTab('home');
setSelectionStage('platform');
if (!maybeAlertRuntimeNotFoundAndReturnHome()) {
if (!maybeAlertWorkNotFoundAndReturnHome()) {
pushAppHistoryPath('/');
}
return;
@@ -6057,7 +6078,7 @@ export function PlatformEntryFlowShellImpl({
setPublicWorkDetailError(null);
setPlatformTab('home');
setSelectionStage('platform');
if (!maybeAlertRuntimeNotFoundAndReturnHome()) {
if (!maybeAlertWorkNotFoundAndReturnHome()) {
pushAppHistoryPath('/');
}
return;
@@ -7387,6 +7408,23 @@ export function PlatformEntryFlowShellImpl({
const user = await getPublicAuthUserByCode(normalizedKeyword);
setSearchedPublicUser(user);
} catch (error) {
if (selectionStage === 'work-detail') {
setSelectedPublicWorkDetail(null);
setSelectedDetailEntry(null);
setSelectedPuzzleDetail(null);
setPuzzleDetailReturnTarget(null);
setPuzzleRun(null);
setPuzzleRuntimeAuthMode('default');
setPuzzleError(null);
setPublicWorkDetailError(null);
setPlatformTab('home');
setSelectionStage('platform');
if (!maybeAlertWorkNotFoundAndReturnHome()) {
pushAppHistoryPath('/');
}
return;
}
setPublicSearchError(
resolveRpgCreationErrorMessage(error, '未找到对应的百梦号或作品号。'),
);
@@ -7407,6 +7445,8 @@ export function PlatformEntryFlowShellImpl({
refreshSquareHoleGallery,
refreshVisualNovelGallery,
squareHoleGalleryEntries,
selectionStage,
setPlatformTab,
visualNovelGalleryEntries,
],
);
@@ -8091,6 +8131,20 @@ export function PlatformEntryFlowShellImpl({
</motion.div>
)}
{selectionStage === 'work-detail' && !selectedPublicWorkDetail && (
<motion.div
key="platform-work-detail-empty"
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -12 }}
className="flex h-full min-h-0 items-center justify-center"
>
<div className="platform-subpanel rounded-2xl px-5 py-4 text-sm text-[var(--platform-text-base)]">
{publicWorkDetailError || '正在读取作品详情...'}
</div>
</motion.div>
)}
{selectionStage === 'work-detail' && selectedPublicWorkDetail && (
<motion.div
key="platform-work-detail"