feat: 完善企业场景多线路由与执行稳定性

补齐平台模板与场景 DSL、预算控制、执行看板和企业场景脚本,增强 Windows 启动/迁移与前端代理和聊天会话记忆,修复执行创建阶段 500 与异步链路排障体验。

Made-with: Cursor
This commit is contained in:
renjianbo
2026-04-09 21:58:53 +08:00
parent bd3f8be781
commit 0608161c82
58 changed files with 6104 additions and 172 deletions

View File

@@ -5,20 +5,26 @@ import router from '@/router'
// 获取API基础URL
const getApiBaseURL = () => {
// 如果在浏览器中优先根据当前主机自动推断避免从公网访问localhost的问题
// 浏览器内:开发模式优先走 Vite 代理vite.config.ts 将 /api 转到 8037避免直连 8037 命中多实例/陈旧 Uvicorn 导致 500
if (typeof window !== 'undefined') {
if (import.meta.env.DEV) {
if (import.meta.env.VITE_API_URL) {
console.log('[API] DEV 使用 VITE_API_URL:', import.meta.env.VITE_API_URL)
return import.meta.env.VITE_API_URL
}
console.log('[API] DEV 走当前站点 + Vite 代理 /api → localhost:8037勿直连 8037')
return ''
}
const hostname = window.location.hostname
const protocol = window.location.protocol
// 如果是localhost或127.0.0.1使用localhost:8037
if (hostname === 'localhost' || hostname === '127.0.0.1') {
const apiUrl = 'http://localhost:8037'
console.log('[API] 使用本地API地址:', apiUrl)
return apiUrl
}
// 对于公网IP必须使用相同的IP地址不能使用localhost
// 使用相同主机名端口8037
const apiUrl = `${protocol}//${hostname}:8037`
console.log('[API] 自动检测API地址:', apiUrl, '(当前主机:', hostname, ')')
return apiUrl
@@ -94,9 +100,22 @@ api.interceptors.response.use(
return Promise.reject(error)
}
// 处理500服务器错误
// 503多为 Redis/Celery 不可用FastAPI HTTPException 使用 detail
if (status === 503) {
const message =
(typeof data?.detail === 'string' ? data.detail : null) ||
data?.message ||
'服务暂时不可用(请检查 Redis 与 Celery Worker'
ElMessage.error(message)
return Promise.reject(error)
}
// 处理500服务器错误DATABASE_ERROR 的 message 由后端区分「缺列/迁移」等DEBUG 时可有 detail
if (status === 500) {
const message = data?.message || '服务器内部错误,请稍后重试'
const message =
(typeof data?.detail === 'string' ? data.detail : null) ||
data?.message ||
'服务器内部错误,请稍后重试'
ElMessage.error(message)
console.error('服务器错误:', data)
return Promise.reject(error)