Files
Genarrative/src/routing/appRoutes.tsx
高物 bb60ca91ef Match3D & Puzzle: runtime UI, assets, drag fix
Backend: stop treating background music as a required draft asset and remove auto-submit/plan for background music; load persisted generated UI/assets into Match3D agent session responses (added helpers to resolve profile id and fetch existing generated assets). Frontend: make Match3D result preview reuse runtime UI styles, unify runtime settings entry, update PuzzleRuntime to apply immediate pointermove transforms (disable drag transition), use SVG clipPath for merged piece rounding, ensure PuzzleRuntimeShell supplies platform theme classes, and adjust related tests. Docs & logs: update decision log, pitfalls and product docs to reflect these changes.
2026-05-15 08:49:59 +08:00

171 lines
4.2 KiB
TypeScript

/* eslint-disable react-refresh/only-export-components */
import { type ComponentType, lazy, type LazyExoticComponent } from 'react';
import { isEdutainmentEntryEnabled } from '../components/platform-entry/platformEdutainmentVisibility';
import { normalizeAppPath } from './appPageRoutes';
type AppRouteComponent = LazyExoticComponent<
ComponentType<Record<string, unknown>>
>;
export type AppRouteMatch =
| {
kind: 'puzzle-playground';
}
| {
kind: 'big-fish-playground';
}
| {
kind: 'match3d-playground';
}
| {
kind: 'bark-battle-playground';
}
| {
kind: 'child-motion-demo';
}
| {
kind: 'baby-love-drawing';
}
| {
kind: 'game';
};
export type ResolvedAppRoute = {
kind: AppRouteMatch['kind'];
loadingEyebrow: string;
loadingText: string;
Component: AppRouteComponent;
componentProps?: Record<string, unknown>;
};
const GameApp = lazy(() => import('../AuthenticatedApp')) as AppRouteComponent;
const BigFishPlaygroundApp = lazy(() => import('../BigFishPlaygroundApp')) as AppRouteComponent;
const Match3DPlaygroundApp = lazy(() => import('../Match3DPlaygroundApp')) as AppRouteComponent;
const BarkBattlePlaygroundApp = lazy(() => import('../BarkBattlePlaygroundApp')) as AppRouteComponent;
const PuzzlePlaygroundApp = lazy(() => import('../PuzzlePlaygroundApp')) as AppRouteComponent;
const ChildMotionDemoApp = lazy(() => import('../ChildMotionDemoApp')) as AppRouteComponent;
const BabyLoveDrawingRuntimeApp = lazy(
() => import('../components/edutainment-runtime/BabyLoveDrawingRuntimeShell'),
) as AppRouteComponent;
function normalizeRoutePath(pathname: string) {
return normalizeAppPath(pathname);
}
export function matchAppRoute(pathname: string): AppRouteMatch {
const normalizedPath = normalizeRoutePath(pathname);
if (normalizedPath === '/puzzle') {
return {
kind: 'puzzle-playground',
};
}
if (normalizedPath === '/big-fish') {
return {
kind: 'big-fish-playground',
};
}
if (normalizedPath === '/match3d') {
return {
kind: 'match3d-playground',
};
}
if (normalizedPath === '/bark-battle') {
return {
kind: 'bark-battle-playground',
};
}
if (
normalizedPath === '/child-motion-demo' &&
isEdutainmentEntryEnabled()
) {
return {
kind: 'child-motion-demo',
};
}
if (
normalizedPath === '/runtime/baby-love-drawing' &&
isEdutainmentEntryEnabled()
) {
return {
kind: 'baby-love-drawing',
};
}
return {
kind: 'game',
};
}
export function resolveAppRoute(pathname: string): ResolvedAppRoute {
const matchedRoute = matchAppRoute(pathname);
if (matchedRoute.kind === 'puzzle-playground') {
return {
kind: 'puzzle-playground',
loadingEyebrow: '正在载入拼图',
loadingText: '正在进入拼图关卡...',
Component: PuzzlePlaygroundApp,
};
}
if (matchedRoute.kind === 'big-fish-playground') {
return {
kind: 'big-fish-playground',
loadingEyebrow: '正在载入大鱼',
loadingText: '正在进入玩法...',
Component: BigFishPlaygroundApp,
};
}
if (matchedRoute.kind === 'match3d-playground') {
return {
kind: 'match3d-playground',
loadingEyebrow: '正在载入抓大鹅',
loadingText: '正在进入消除关卡...',
Component: Match3DPlaygroundApp,
};
}
if (matchedRoute.kind === 'bark-battle-playground') {
return {
kind: 'bark-battle-playground',
loadingEyebrow: '正在载入汪汪声浪',
loadingText: '正在进入竖屏声浪竞技场...',
Component: BarkBattlePlaygroundApp,
};
}
if (matchedRoute.kind === 'child-motion-demo') {
return {
kind: 'child-motion-demo',
loadingEyebrow: '正在载入热身关',
loadingText: '正在进入寓教于乐 Demo...',
Component: ChildMotionDemoApp,
};
}
if (matchedRoute.kind === 'baby-love-drawing') {
return {
kind: 'baby-love-drawing',
loadingEyebrow: '正在载入宝贝爱画',
loadingText: '正在进入画板...',
Component: BabyLoveDrawingRuntimeApp,
};
}
return {
kind: 'game',
loadingEyebrow: '正在载入游戏',
loadingText: '正在加载内容',
Component: GameApp,
};
}