创作数据流程收束
This commit is contained in:
@@ -9,7 +9,7 @@ describe('matchAppRoute', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('routes deprecated editor paths back to the main game', () => {
|
||||
it('routes former standalone editor paths back to the main game', () => {
|
||||
expect(matchAppRoute('/item-editor/tools')).toEqual({
|
||||
kind: 'game',
|
||||
});
|
||||
@@ -26,10 +26,4 @@ describe('matchAppRoute', () => {
|
||||
kind: 'game',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the sprite tool route', () => {
|
||||
expect(matchAppRoute('/sprite-tool')).toEqual({
|
||||
kind: 'qwen-sprite-tool',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,9 +9,6 @@ type AppRouteComponent = LazyExoticComponent<
|
||||
export type AppRouteMatch =
|
||||
| {
|
||||
kind: 'game';
|
||||
}
|
||||
| {
|
||||
kind: 'qwen-sprite-tool';
|
||||
};
|
||||
|
||||
export type ResolvedAppRoute = {
|
||||
@@ -23,15 +20,6 @@ export type ResolvedAppRoute = {
|
||||
};
|
||||
|
||||
const GameApp = lazy(() => import('../AuthenticatedApp')) as AppRouteComponent;
|
||||
const QwenSpriteToolApp = lazy(
|
||||
() => import('../tools/QwenSpriteSheetTool'),
|
||||
) as AppRouteComponent;
|
||||
|
||||
const QWEN_SPRITE_TOOL_PREFIXES = [
|
||||
'/qwen-sprite-tool',
|
||||
'/sprite-tool',
|
||||
'/pixelmotion-qwen',
|
||||
];
|
||||
|
||||
function normalizeRoutePath(pathname: string) {
|
||||
const trimmedPathname = pathname.trim().toLowerCase();
|
||||
@@ -43,25 +31,8 @@ function normalizeRoutePath(pathname: string) {
|
||||
return trimmedPathname.replace(/\/+$/u, '');
|
||||
}
|
||||
|
||||
function matchesRoutePrefix(pathname: string, prefix: string) {
|
||||
const normalizedPrefix = normalizeRoutePath(prefix);
|
||||
|
||||
return (
|
||||
pathname === normalizedPrefix || pathname.startsWith(`${normalizedPrefix}/`)
|
||||
);
|
||||
}
|
||||
|
||||
export function matchAppRoute(pathname: string): AppRouteMatch {
|
||||
const normalizedPathname = normalizeRoutePath(pathname);
|
||||
const isQwenSpriteToolRoute = QWEN_SPRITE_TOOL_PREFIXES.some((prefix) =>
|
||||
matchesRoutePrefix(normalizedPathname, prefix),
|
||||
);
|
||||
|
||||
if (isQwenSpriteToolRoute) {
|
||||
return {
|
||||
kind: 'qwen-sprite-tool',
|
||||
};
|
||||
}
|
||||
void normalizeRoutePath(pathname);
|
||||
|
||||
return {
|
||||
kind: 'game',
|
||||
@@ -71,15 +42,6 @@ export function matchAppRoute(pathname: string): AppRouteMatch {
|
||||
export function resolveAppRoute(pathname: string): ResolvedAppRoute {
|
||||
const matchedRoute = matchAppRoute(pathname);
|
||||
|
||||
if (matchedRoute.kind === 'qwen-sprite-tool') {
|
||||
return {
|
||||
kind: matchedRoute.kind,
|
||||
loadingEyebrow: '正在载入精灵表工坊',
|
||||
loadingText: '正在载入 Qwen 精灵表工具...',
|
||||
Component: QwenSpriteToolApp,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'game',
|
||||
loadingEyebrow: '正在载入游戏',
|
||||
|
||||
Reference in New Issue
Block a user