File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,22 @@ npm run kill:all # 关闭常见开发端口
100100npm 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 提交到仓库
Original file line number Diff line number Diff line change 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."
You can’t perform that action at this time.
0 commit comments