feat: integrate robot assembly and simulation with resilient loading
Add backend-driven assembly and simulation experiences, MAKE branding, mobile rendering budgets and desktop-only CAD/PCB routes. Improve logo loading progress, document image recovery and URDF request handling; include dev packaging and regression coverage.
This commit is contained in:
+9
-5
@@ -5,9 +5,9 @@
|
||||
// dev-vibemake.robotquan.com、localhost、127.0.0.1、局域网 IP → https://dev-vibemake-api.robotquan.com
|
||||
// vibemake.robotquan.com 等正式域名 → https://vibemake-api.robotquan.com
|
||||
//
|
||||
// 本地:node scripts/server.mjs → http://localhost:8091
|
||||
// 本地:node scripts/server.mjs → http://localhost:8090
|
||||
// 线上浏览器直接请求后端域名(见 js/api.js 的 API_HOSTS),这里的域名判断只用于本地调试
|
||||
// 环境变量:PORT 端口(默认 8091);API_TARGET 强制所有域名都转发到这个后端;API_DEV / API_PROD 改两个后端地址;
|
||||
// 环境变量:PORT 端口(默认 8090);API_TARGET 强制所有域名都转发到这个后端;API_DEV / API_PROD 改两个后端地址;
|
||||
// SITE_ROOT 页面文件目录(默认:在 scripts/ 里运行时是项目根目录,在 dist/ 里运行时是 dist 本身)
|
||||
import http from 'node:http';
|
||||
import https from 'node:https';
|
||||
@@ -15,10 +15,12 @@ import zlib from 'node:zlib';
|
||||
import { createReadStream, existsSync, statSync } from 'node:fs';
|
||||
import { basename, dirname, extname, join, normalize, resolve, sep } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { MODEL_ASSET_ROUTE } from '../js/model-assets.js';
|
||||
import { proxyModelAsset } from './model-assets-proxy.mjs';
|
||||
|
||||
const HERE = dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT = resolve(process.env.SITE_ROOT || (basename(HERE) === 'scripts' ? join(HERE, '..') : HERE));
|
||||
const PORT = Number(process.env.PORT || 8091);
|
||||
const PORT = Number(process.env.PORT || 8090);
|
||||
const API_DEV = process.env.API_DEV || 'https://dev-vibemake-api.robotquan.com';
|
||||
const API_PROD = process.env.API_PROD || 'https://vibemake-api.robotquan.com';
|
||||
|
||||
@@ -71,12 +73,13 @@ const TYPES = {
|
||||
'.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.mjs': 'text/javascript; charset=utf-8',
|
||||
'.css': 'text/css; charset=utf-8', '.json': 'application/json; charset=utf-8', '.md': 'text/markdown; charset=utf-8',
|
||||
'.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml',
|
||||
'.ico': 'image/x-icon', '.urdf': 'application/xml', '.xml': 'application/xml', '.stl': 'model/stl',
|
||||
'.ico': 'image/x-icon', '.webmanifest': 'application/manifest+json', '.urdf': 'application/xml', '.xml': 'application/xml', '.stl': 'model/stl',
|
||||
'.glb': 'model/gltf-binary', '.gltf': 'model/gltf+json', '.obj': 'text/plain', '.dae': 'model/vnd.collada+xml',
|
||||
'.wasm': 'application/wasm',
|
||||
};
|
||||
const COMPRESS = /\.(html|js|mjs|css|json|md|svg|urdf|xml|stl|obj|dae|gltf)$/i;
|
||||
const LONG_CACHE = /\.(stl|dae|obj|glb|gltf|urdf|png|jpe?g|webp|svg|ico)$/i;
|
||||
const HIDDEN = /(^|\/)(\.|server\.mjs$|package\.json$|scripts\/|docs\/|README\.md$|DEPLOY\.md$|nginx\.conf)/;
|
||||
const HIDDEN = /(^|\/)(\.|server\.mjs$|package\.json$|scripts\/|sandbox\/|docs\/|README\.md$|DEPLOY\.md$|nginx\.conf)/;
|
||||
|
||||
function sendFile(req, res, file) {
|
||||
let st;
|
||||
@@ -131,6 +134,7 @@ function serveStatic(req, res) {
|
||||
|
||||
http.createServer((req, res) => {
|
||||
if (req.url === '/api' || req.url.startsWith('/api/')) proxy(req, res);
|
||||
else if (req.url.startsWith(`${MODEL_ASSET_ROUTE}/`)) proxyModelAsset(req, res);
|
||||
else if (req.method === 'GET' || req.method === 'HEAD') serveStatic(req, res);
|
||||
else res.writeHead(405).end();
|
||||
}).listen(PORT, () => {
|
||||
|
||||
Reference in New Issue
Block a user