b069e54b89
- 添加前端版本号显示(桌面端和移动端) - 实现 GitHub Actions 自动构建和推送 Docker 镜像 - 实现删除 release 时自动删除对应 Docker 镜像 - 支持版本号格式:v数字.数字.数字 或 v数字.数字.数字-后缀 - 添加版本号管理文档 - 更新 Dockerfile 和部署脚本支持版本号构建参数
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
// 加载环境变量
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
|
|
// 从环境变量获取后端地址,用于开发环境代理
|
|
// 如果未设置,使用默认值 localhost:8000
|
|
const API_URL = env.VITE_API_URL || 'http://localhost:8000'
|
|
const WS_URL = env.VITE_WS_URL || 'ws://localhost:8000'
|
|
|
|
// 从环境变量获取版本信息(构建时注入)
|
|
const VERSION = env.VERSION || 'dev'
|
|
const GIT_TAG = env.GIT_TAG || ''
|
|
const GITHUB_REPO_URL = env.GITHUB_REPO_URL || 'https://github.com/WrBug/PolyHermes'
|
|
|
|
return {
|
|
plugins: [react()],
|
|
define: {
|
|
// 注入版本信息到全局变量
|
|
'window.__VERSION__': JSON.stringify({
|
|
version: VERSION,
|
|
gitTag: GIT_TAG,
|
|
githubRepoUrl: GITHUB_REPO_URL
|
|
})
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
'/api': {
|
|
target: API_URL,
|
|
changeOrigin: true
|
|
},
|
|
'/ws': {
|
|
target: WS_URL,
|
|
ws: true,
|
|
changeOrigin: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|