This commit is contained in:
2026-04-25 11:22:03 +08:00
parent 31f350d499
commit a6029639b0
12 changed files with 518 additions and 63 deletions

View File

@@ -9,6 +9,18 @@ describe('matchAppRoute', () => {
});
});
it('routes puzzle playground path to the standalone puzzle runtime', () => {
expect(matchAppRoute('/puzzle')).toEqual({
kind: 'puzzle-playground',
});
});
it('routes big fish playground path to the standalone big fish runtime', () => {
expect(matchAppRoute('/BIG-FISH/')).toEqual({
kind: 'big-fish-playground',
});
});
it('routes former standalone editor paths back to the main game', () => {
expect(matchAppRoute('/item-editor/tools')).toEqual({
kind: 'game',

View File

@@ -7,6 +7,12 @@ type AppRouteComponent = LazyExoticComponent<
>;
export type AppRouteMatch =
| {
kind: 'puzzle-playground';
}
| {
kind: 'big-fish-playground';
}
| {
kind: 'game';
};
@@ -20,6 +26,8 @@ export type ResolvedAppRoute = {
};
const GameApp = lazy(() => import('../AuthenticatedApp')) as AppRouteComponent;
const BigFishPlaygroundApp = lazy(() => import('../BigFishPlaygroundApp')) as AppRouteComponent;
const PuzzlePlaygroundApp = lazy(() => import('../PuzzlePlaygroundApp')) as AppRouteComponent;
function normalizeRoutePath(pathname: string) {
const trimmedPathname = pathname.trim().toLowerCase();
@@ -32,7 +40,19 @@ function normalizeRoutePath(pathname: string) {
}
export function matchAppRoute(pathname: string): AppRouteMatch {
void normalizeRoutePath(pathname);
const normalizedPath = normalizeRoutePath(pathname);
if (normalizedPath === '/puzzle') {
return {
kind: 'puzzle-playground',
};
}
if (normalizedPath === '/big-fish') {
return {
kind: 'big-fish-playground',
};
}
return {
kind: 'game',
@@ -42,6 +62,24 @@ export function matchAppRoute(pathname: string): AppRouteMatch {
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,
};
}
return {
kind: 'game',
loadingEyebrow: '正在载入游戏',