2026-04-23 19:35:04 +08:00
|
|
|
|
import type { Plugin } from 'vite';
|
|
|
|
|
|
|
|
|
|
|
|
import { copyFileSync, mkdirSync } from 'node:fs';
|
|
|
|
|
|
import { createRequire } from 'node:module';
|
|
|
|
|
|
import { dirname, resolve } from 'node:path';
|
|
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
|
|
2024-07-29 00:19:26 +08:00
|
|
|
|
import { defineConfig } from '@vben/vite-config';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
|
2026-04-23 19:35:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 启动/构建时把 lottie-web 的 light 播放器从 node_modules 拷到 public/
|
|
|
|
|
|
* 供 loading.html 以 <script src="/lottie_light.min.js"> 方式加载。
|
|
|
|
|
|
*
|
|
|
|
|
|
* 每次 configResolved 都无条件覆盖:文件约 160KB,成本可忽略;
|
|
|
|
|
|
* 且避免依赖 mtime 比较(pnpm 安装后 node_modules 的 mtime 与上游
|
|
|
|
|
|
* 发布时间无关,mtime 比较会误判为"已是最新"而不更新)。
|
|
|
|
|
|
*/
|
|
|
|
|
|
function copyLottiePlayer(): Plugin {
|
|
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
|
const src = require.resolve('lottie-web/build/player/lottie_light.min.js');
|
|
|
|
|
|
const dest = resolve(
|
|
|
|
|
|
dirname(fileURLToPath(import.meta.url)),
|
|
|
|
|
|
'public/lottie_light.min.js',
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
name: 'web-antd:copy-lottie-player',
|
|
|
|
|
|
configResolved: () => {
|
|
|
|
|
|
mkdirSync(dirname(dest), { recursive: true });
|
|
|
|
|
|
copyFileSync(src, dest);
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-13 21:00:31 +08:00
|
|
|
|
export default defineConfig(async () => {
|
|
|
|
|
|
return {
|
2024-07-29 00:19:26 +08:00
|
|
|
|
application: {},
|
2024-07-13 21:00:31 +08:00
|
|
|
|
vite: {
|
2026-04-23 19:35:04 +08:00
|
|
|
|
plugins: [copyLottiePlayer()],
|
2024-07-13 21:00:31 +08:00
|
|
|
|
server: {
|
2026-01-18 17:04:03 +08:00
|
|
|
|
allowedHosts: true,
|
2024-07-13 21:00:31 +08:00
|
|
|
|
proxy: {
|
重构: aiot 模块重命名为 video,WVP 凭据移至环境变量
路径重命名:
- api/aiot/{alarm,device,edge,request} → api/video/{alarm,device,edge,request}
- views/aiot/{alarm,device,edge} → views/video/{alarm,device,edge}
- vite.config.mts 代理路径 /admin-api/aiot/* → /admin-api/video/*
video/request.ts 改造:
- WVP 用户名/密码 MD5 改读 import.meta.env,不再写死在源码里
- force 截图失败时补一条 console.debug,便于回溯 COS 图片加载异常
video/alarm/index.ts 顺带清理:
- 移除无调用方的重复 API getRecentAlerts(与 getAlertPage 重叠)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:57:44 +08:00
|
|
|
|
// ==================== Video 模块统一路由 ====================
|
2026-02-09 10:24:47 +08:00
|
|
|
|
|
重构: aiot 模块重命名为 video,WVP 凭据移至环境变量
路径重命名:
- api/aiot/{alarm,device,edge,request} → api/video/{alarm,device,edge,request}
- views/aiot/{alarm,device,edge} → views/video/{alarm,device,edge}
- vite.config.mts 代理路径 /admin-api/aiot/* → /admin-api/video/*
video/request.ts 改造:
- WVP 用户名/密码 MD5 改读 import.meta.env,不再写死在源码里
- force 截图失败时补一条 console.debug,便于回溯 COS 图片加载异常
video/alarm/index.ts 顺带清理:
- 移除无调用方的重复 API getRecentAlerts(与 getAlertPage 重叠)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:57:44 +08:00
|
|
|
|
// video/alarm, video/edge -> 告警服务 :8000(直通)
|
|
|
|
|
|
'/admin-api/video/alarm': {
|
2026-02-06 16:41:00 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
|
},
|
重构: aiot 模块重命名为 video,WVP 凭据移至环境变量
路径重命名:
- api/aiot/{alarm,device,edge,request} → api/video/{alarm,device,edge,request}
- views/aiot/{alarm,device,edge} → views/video/{alarm,device,edge}
- vite.config.mts 代理路径 /admin-api/aiot/* → /admin-api/video/*
video/request.ts 改造:
- WVP 用户名/密码 MD5 改读 import.meta.env,不再写死在源码里
- force 截图失败时补一条 console.debug,便于回溯 COS 图片加载异常
video/alarm/index.ts 顺带清理:
- 移除无调用方的重复 API getRecentAlerts(与 getAlertPage 重叠)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:57:44 +08:00
|
|
|
|
'/admin-api/video/edge': {
|
2026-02-06 16:41:00 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
|
},
|
2026-02-11 09:57:29 +08:00
|
|
|
|
// 告警截图静态文件 -> 告警服务 :8000
|
|
|
|
|
|
'/uploads': {
|
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
|
},
|
|
|
|
|
|
// Edge 本地截图(COS 未配置时回退)-> 告警服务 :8000
|
|
|
|
|
|
'/captures': {
|
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
|
},
|
|
|
|
|
|
// COS 存储相关接口 -> 告警服务 :8000
|
重构: aiot 模块重命名为 video,WVP 凭据移至环境变量
路径重命名:
- api/aiot/{alarm,device,edge,request} → api/video/{alarm,device,edge,request}
- views/aiot/{alarm,device,edge} → views/video/{alarm,device,edge}
- vite.config.mts 代理路径 /admin-api/aiot/* → /admin-api/video/*
video/request.ts 改造:
- WVP 用户名/密码 MD5 改读 import.meta.env,不再写死在源码里
- force 截图失败时补一条 console.debug,便于回溯 COS 图片加载异常
video/alarm/index.ts 顺带清理:
- 移除无调用方的重复 API getRecentAlerts(与 getAlertPage 重叠)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:57:44 +08:00
|
|
|
|
'/admin-api/video/storage': {
|
2026-02-11 09:57:29 +08:00
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
target: 'http://127.0.0.1:8000',
|
|
|
|
|
|
},
|
2026-02-09 10:24:47 +08:00
|
|
|
|
|
2026-04-17 09:14:00 +08:00
|
|
|
|
// ==================== 芋道主平台 ====================
|
2026-04-23 19:33:37 +08:00
|
|
|
|
// 所有 system/*、infra/*、video/device/* 等业务接口 -> 芋道网关 48080
|
|
|
|
|
|
// video 微服务已挂到 gateway,不再直连 WVP :18080
|
2025-03-18 13:06:04 +08:00
|
|
|
|
'/admin-api': {
|
2024-07-13 21:00:31 +08:00
|
|
|
|
changeOrigin: true,
|
2025-03-18 13:06:04 +08:00
|
|
|
|
rewrite: (path) => path.replace(/^\/admin-api/, ''),
|
2026-04-17 09:14:00 +08:00
|
|
|
|
// mock代理目标地址
|
2025-03-18 13:06:04 +08:00
|
|
|
|
target: 'http://localhost:48080/admin-api',
|
2024-07-13 21:00:31 +08:00
|
|
|
|
ws: true,
|
|
|
|
|
|
},
|
2024-05-19 21:20:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-07-13 21:00:31 +08:00
|
|
|
|
};
|
2024-05-19 21:20:42 +08:00
|
|
|
|
});
|