feat: bootstrap auto virtual tryon admin frontend

This commit is contained in:
afei A
2026-03-27 23:38:50 +08:00
commit 98c6b741d6
119 changed files with 19046 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import {
GARMENT_LIBRARY_FIXTURES,
MODEL_LIBRARY_FIXTURES,
SCENE_LIBRARY_FIXTURES,
} from "@/lib/mock/libraries";
import { RouteError, jsonSuccess, withErrorHandling } from "@/lib/http/response";
import type { LibraryItemVM, LibraryType } from "@/lib/types/view-models";
type RouteContext = {
params: Promise<{
libraryType: string;
}>;
};
const LIBRARY_FIXTURE_MAP: Record<LibraryType, LibraryItemVM[]> = {
models: MODEL_LIBRARY_FIXTURES,
scenes: SCENE_LIBRARY_FIXTURES,
garments: GARMENT_LIBRARY_FIXTURES,
};
const MESSAGE = "资源库当前使用占位数据,真实后端接口尚未提供。";
function isLibraryType(value: string): value is LibraryType {
return Object.hasOwn(LIBRARY_FIXTURE_MAP, value);
}
export async function GET(_request: Request, context: RouteContext) {
return withErrorHandling(async () => {
const { libraryType } = await context.params;
if (!isLibraryType(libraryType)) {
throw new RouteError(404, "NOT_FOUND", "不支持的资源库类型。");
}
return jsonSuccess(
{
items: LIBRARY_FIXTURE_MAP[libraryType],
},
{
mode: "placeholder",
message: MESSAGE,
},
);
});
}