fix:优化启动配置

This commit is contained in:
Daniel
2026-03-07 23:47:29 +08:00
parent c3d219efc1
commit 7db497bc94
6 changed files with 219 additions and 4 deletions

21
run.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# 部署流程:拉代码 → 安装依赖 → 构建前端到 dist/ → 启动后端 API5599
# 若 Nginx 未反代 /api请先设置 API_BASE_URL 再执行,例如:
# export API_BASE_URL="http://你的域名或IP:5599"
# ./run.sh
# 若 Nginx 已将 /api 反代到本机 5599可留空 api.config.jsonapiBase 为空即可)。
set -e
cd "$(dirname "$0")"
git fetch origin && git reset --hard origin/master
npm install --no-audit --no-fund
# 若设置了 API_BASE_URL则写入 api.config.json供 build 复制到 dist/
if [ -n "$API_BASE_URL" ]; then
echo "[run.sh] 使用 API_BASE_URL=$API_BASE_URL"
node -e "require('fs').writeFileSync('api.config.json', JSON.stringify({ apiBase: process.env.API_BASE_URL }, null, 2))"
fi
node build.js
bash start-api.sh