Merge pull request '前端:修复多分支部署时静态资源的路径问题' (#52) from feature-nxdev into main

Reviewed-on: #52
This commit is contained in:
西街长安 2026-01-29 22:54:48 +08:00
commit 8938dd40d4
2 changed files with 18 additions and 6 deletions

View File

@ -1,4 +1,4 @@
VITE_API_BASE_URL = http://localhost:5202/api
VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
#VITE_API_BASE_URL = http://192.168.5.116:7070/api
#VITE_SIGNALR_BASE_URL = http://192.168.5.116:7070/chat
#VITE_API_BASE_URL = http://localhost:5202/api
#VITE_SIGNALR_BASE_URL = http://localhost:5202/chat
VITE_API_BASE_URL = https://im.test.nxsir.cn/api
VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat

View File

@ -4,9 +4,20 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({
base: './',
export default defineConfig(( { command } ) => {
let branch = process.env.BRANCH || 'main'
// 1⃣ dev 模式:永远 /
if (command === 'serve') {
branch = '/'
}else{
branch = `/${branch}/`
}
return {
base: branch,
build: {
sourcemap: true
},
@ -19,4 +30,5 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
}
})