Skip to content

Commit 9c22cb9

Browse files
chore(deploy): add Baota static deploy script and docs
1 parent 714d406 commit 9c22cb9

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ npm run kill:all # 关闭常见开发端口
100100
npm run restart # 重启前后端开发环境
101101
```
102102

103+
## 宝塔部署(静态站点)
104+
105+
项目提供一键脚本将最新 `dist/` 同步到宝塔站点目录:
106+
107+
```bash
108+
./scripts/deploy-bt.sh
109+
# 或自定义目录
110+
./scripts/deploy-bt.sh /www/wwwroot/Web/TextCreateImage
111+
```
112+
113+
脚本行为:
114+
115+
- 本地执行 `npm run build`
116+
- 使用 `rsync` 覆盖站点静态资源(保留 `.htaccess` / `.user.ini`
117+
- 适合将 Vite 前端直接发布到宝塔 Nginx 站点
118+
103119
## 安全建议
104120

105121
- 不要把 API Key 提交到仓库

scripts/deploy-bt.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
TARGET_DIR="${1:-/www/wwwroot/Web/TextCreateImage}"
6+
7+
cd "$REPO_DIR"
8+
9+
echo "[deploy-bt] Building frontend..."
10+
npm run build
11+
12+
echo "[deploy-bt] Syncing dist -> $TARGET_DIR"
13+
install -d "$TARGET_DIR"
14+
15+
# Keep panel-managed files while replacing frontend assets.
16+
rsync -av --delete \
17+
--chown=www:www \
18+
--exclude='.htaccess' \
19+
--exclude='.user.ini' \
20+
--exclude='404.html' \
21+
dist/ "$TARGET_DIR/"
22+
23+
# Optional SPA fallback file for some panel presets.
24+
if [ ! -f "$TARGET_DIR/404.html" ]; then
25+
cp "$REPO_DIR/dist/index.html" "$TARGET_DIR/404.html"
26+
chown www:www "$TARGET_DIR/404.html" || true
27+
fi
28+
29+
echo "[deploy-bt] Done."

0 commit comments

Comments
 (0)