@@ -9,24 +9,15 @@ describe('matchAppRoute', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('routes item editor paths to the preset editor items tab', () => {
|
||||
it('routes deprecated editor paths back to the main game', () => {
|
||||
expect(matchAppRoute('/item-editor/tools')).toEqual({
|
||||
kind: 'preset-editor',
|
||||
initialTab: 'items',
|
||||
kind: 'game',
|
||||
});
|
||||
});
|
||||
|
||||
it('routes behavior editor paths to the functions tab', () => {
|
||||
expect(matchAppRoute('/behavior-editor')).toEqual({
|
||||
kind: 'preset-editor',
|
||||
initialTab: 'functions',
|
||||
kind: 'game',
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts nested preset editor paths with trailing slashes', () => {
|
||||
expect(matchAppRoute('/NPC-EDITOR/profiles/')).toEqual({
|
||||
kind: 'preset-editor',
|
||||
initialTab: 'npcs',
|
||||
kind: 'game',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,4 +26,10 @@ describe('matchAppRoute', () => {
|
||||
kind: 'game',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the sprite tool route', () => {
|
||||
expect(matchAppRoute('/sprite-tool')).toEqual({
|
||||
kind: 'qwen-sprite-tool',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
import { type ComponentType, lazy, type LazyExoticComponent } from 'react';
|
||||
|
||||
import type { PresetEditorTab } from '../components/PresetEditor';
|
||||
|
||||
type AppRouteComponent = LazyExoticComponent<
|
||||
ComponentType<Record<string, unknown>>
|
||||
>;
|
||||
@@ -12,10 +10,6 @@ export type AppRouteMatch =
|
||||
| {
|
||||
kind: 'game';
|
||||
}
|
||||
| {
|
||||
kind: 'preset-editor';
|
||||
initialTab: PresetEditorTab;
|
||||
}
|
||||
| {
|
||||
kind: 'qwen-sprite-tool';
|
||||
};
|
||||
@@ -29,43 +23,10 @@ export type ResolvedAppRoute = {
|
||||
};
|
||||
|
||||
const GameApp = lazy(() => import('../AuthenticatedApp')) as AppRouteComponent;
|
||||
const PresetEditorApp = lazy(async () => {
|
||||
const module = await import('../components/PresetEditor');
|
||||
|
||||
return {
|
||||
default: module.PresetEditor,
|
||||
};
|
||||
}) as AppRouteComponent;
|
||||
const QwenSpriteToolApp = lazy(
|
||||
() => import('../tools/QwenSpriteSheetTool'),
|
||||
) as AppRouteComponent;
|
||||
|
||||
const PRESET_EDITOR_ROUTES: Array<{
|
||||
prefixes: string[];
|
||||
initialTab: PresetEditorTab;
|
||||
}> = [
|
||||
{
|
||||
prefixes: ['/character-asset-studio', '/asset-studio'],
|
||||
initialTab: 'assets',
|
||||
},
|
||||
{
|
||||
prefixes: ['/function-editor', '/behavior-editor'],
|
||||
initialTab: 'functions',
|
||||
},
|
||||
{
|
||||
prefixes: ['/item-editor'],
|
||||
initialTab: 'items',
|
||||
},
|
||||
{
|
||||
prefixes: ['/npc-editor'],
|
||||
initialTab: 'npcs',
|
||||
},
|
||||
{
|
||||
prefixes: ['/preset-editor'],
|
||||
initialTab: 'characters',
|
||||
},
|
||||
];
|
||||
|
||||
const QWEN_SPRITE_TOOL_PREFIXES = [
|
||||
'/qwen-sprite-tool',
|
||||
'/sprite-tool',
|
||||
@@ -102,19 +63,6 @@ export function matchAppRoute(pathname: string): AppRouteMatch {
|
||||
};
|
||||
}
|
||||
|
||||
const presetRoute = PRESET_EDITOR_ROUTES.find((route) =>
|
||||
route.prefixes.some((prefix) =>
|
||||
matchesRoutePrefix(normalizedPathname, prefix),
|
||||
),
|
||||
);
|
||||
|
||||
if (presetRoute) {
|
||||
return {
|
||||
kind: 'preset-editor',
|
||||
initialTab: presetRoute.initialTab,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'game',
|
||||
};
|
||||
@@ -132,18 +80,6 @@ export function resolveAppRoute(pathname: string): ResolvedAppRoute {
|
||||
};
|
||||
}
|
||||
|
||||
if (matchedRoute.kind === 'preset-editor') {
|
||||
return {
|
||||
kind: matchedRoute.kind,
|
||||
loadingEyebrow: '正在载入编辑器',
|
||||
loadingText: '正在载入编辑器...',
|
||||
Component: PresetEditorApp,
|
||||
componentProps: {
|
||||
initialTab: matchedRoute.initialTab,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'game',
|
||||
loadingEyebrow: '正在载入游戏',
|
||||
|
||||
Reference in New Issue
Block a user