Files
opendance-web/web-server/admin/vite.config.ts
T
opendance 39bfd390e3 feat(models): 模型一律转 VRM(契约 0.5.0)+ 可用性门槛 + 管理端版本号展示
按《DSH 开发文档 v1.6》4.9 与第十一章实现,Web 端第一步:

1. 契约先行(先改 contracts/ 再同步三端):
   * model-formats.md -> 0.5.0:模型主力格式改为 VRM,所有上传模型一律转 VRM
     (.pmx/.fbx: assimp -> GLB -> VRM;glb/gltf: 包装为 VRM);
     新增 humanoid 硬门槛与"不达标回退 GLB + usable=false"的交付表;
   * data-models.md -> 0.5.0:Model 新增 usable / unusableReason,明确
     usable=false 不进入 catalog/export;format 说明改为主力 vrm;
   * VERSION 与 contract-versions.ts 同步(三端契约文件逐字节一致)。
2. 实现:
   * MODEL_CONVERT_FORMAT 默认改为 vrm(deploy/.env.example 同步);
   * 新增 isUsableModel()/unusableReason():usable 等价于"已产出 VRM",
     原因从 stats 里带出 humanoid 覆盖度;
   * catalog/export 与 catalog/version 指纹都只统计 format=vrm 的已发布模型,
     resolveDefaultModelId 同样只在可用模型中选;
   * 管理端:模型列表与审核面板显示「不可用」及原因;
   * 管理端左下角展示当前版本号(构建期从 web-server/package.json 注入
     __APP_VERSION__,与 GET /health 同源),并去掉写死的"契约 rest-api 0.1.0"。
3. 测试:新增 test/model-usability.spec.ts 5 项;规模 16 文件 / 225 项。
4. 版本 0.3.0。
2026-09-17 00:05:02 +08:00

46 lines
1.3 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
const API_TARGET = 'http://localhost:3000';
/**
* 版本号唯一来源:`web-server/package.json`(与 `GET /health` 的 version 同源)。
* 构建期注入 `__APP_VERSION__`,管理端左下角直接展示,避免代码里再手写一份
* (见开发文档 v1.5 第十一章「版本号展示」)。
*/
const serverPackage = JSON.parse(
readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'),
) as { version?: string };
const APP_VERSION = serverPackage.version ?? '0.0.0';
// base './' 让产物可挂在任意子路径;开发期 /api 与 /health 代理到 NestJS 服务。
export default defineConfig({
base: './',
define: {
__APP_VERSION__: JSON.stringify(APP_VERSION),
},
plugins: [react()],
server: {
port: 5173,
strictPort: true,
proxy: {
'/api': {
target: API_TARGET,
changeOrigin: true,
},
'/health': {
target: API_TARGET,
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
sourcemap: false,
// VRM 预览分包内是 three.js 本体(约 750 kB),属于预期体积。
chunkSizeWarningLimit: 900,
},
});