chore: release v1.0.3
Deploy / build-windows (push) Failing after 9s
Deploy / build-linux-web (push) Successful in 51s
Deploy / release-deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-05-28 22:39:04 +08:00
parent ec7596e272
commit 75e3b934bc
29 changed files with 386 additions and 150 deletions
+93 -7
View File
@@ -32,6 +32,9 @@ BACKEND_PID_FILE="$LOG_DIR/backend.pid"
BACKEND_HASH_FILE="$LOG_DIR/backend.hash"
WEB_LOG="$LOG_DIR/web.log"
WEB_PID_FILE="$LOG_DIR/web.pid"
ELEVENTY_LOG="$LOG_DIR/eleventy.log"
ELEVENTY_PID_FILE="$LOG_DIR/eleventy.pid"
PROXY_PID_FILE="$LOG_DIR/proxy.pid"
mkdir -p "$LOG_DIR"
@@ -115,6 +118,79 @@ RUN_BACKEND=true
RUN_FRONTEND=true # macOS
RUN_WEB=false
cmd_marketing() {
local WEB_DIR="$ROOT/web"
local FLUTTER_WEB_PORT=9090
local ELEVENTY_PORT=3001
local PROXY_PORT=3000
# 检查依赖
if ! command -v node &>/dev/null; then
error "未找到 node,请安装 Node.js"
exit 1
fi
if ! command -v flutter &>/dev/null; then
error "未找到 flutter"
exit 1
fi
# 清理旧进程
for pid_file in "$ELEVENTY_PID_FILE" "$PROXY_PID_FILE" "$WEB_PID_FILE"; do
if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
kill "$pid" 2>/dev/null || true
rm -f "$pid_file"
fi
done
for port in $ELEVENTY_PORT $FLUTTER_WEB_PORT $PROXY_PORT; do
pids=$(lsof -ti:"$port" 2>/dev/null || true)
[ -n "$pids" ] && echo "$pids" | xargs kill -9 2>/dev/null || true
done
sleep 0.5
# 启动后端(如已运行则跳过)
if ! curl -s -o /dev/null http://localhost:8080/health 2>/dev/null; then
info "启动后端..."
cd "$BACKEND_DIR"
go run main.go >>"$BACKEND_LOG" 2>&1 &
local bp=$!
echo "$bp" > "$BACKEND_PID_FILE"
wait_backend
cd "$ROOT"
else
success "后端已在运行 → http://localhost:8080"
fi
# 启动 Eleventy(宣传站)在后台,3001 口
info "启动 Eleventy(宣传站后台)→ :${ELEVENTY_PORT}..."
cd "$WEB_DIR"
npx eleventy --serve --port=$ELEVENTY_PORT >>"$ELEVENTY_LOG" 2>&1 &
echo "$!" > "$ELEVENTY_PID_FILE"
cd "$ROOT"
# 启动代理(后台)
info "启动代理(后台)→ http://localhost:${PROXY_PORT}..."
PROXY_PORT=$PROXY_PORT ELEVENTY_PORT=$ELEVENTY_PORT FLUTTER_PORT=$FLUTTER_WEB_PORT \
node "$ROOT/scripts/dev-proxy.js" >>"$LOG_DIR/proxy.log" 2>&1 &
echo "$!" > "$PROXY_PID_FILE"
sleep 1
echo ""
success "代理已就绪:http://localhost:${PROXY_PORT}(宣传站)/ http://localhost:${PROXY_PORT}/app/Flutter"
echo -e " ${CYAN}Eleventy 日志:tail -f $ELEVENTY_LOG${NC}"
echo ""
info "在前台启动 Flutter Web(支持热重载,按 r 重载,按 q 退出)..."
echo ""
# Flutter 在前台运行,支持交互热重载
cd "$CLIENT_DIR"
flutter pub get
flutter run -d chrome --web-port "$FLUTTER_WEB_PORT" \
"--dart-define=BASE_URL=http://localhost:8080" \
"--dart-define=PUBLIC_URL=http://localhost:${PROXY_PORT}" \
"--dart-define=APP_VERSION=dev"
}
show_help() {
echo "用法: sh scripts/dev.sh <命令> [选项]"
echo ""
@@ -126,6 +202,7 @@ show_help() {
echo " --backend-only 仅启动后端"
echo " --frontend-only 仅启动前端(macOS"
echo " --web-only 仅启动前端(Web"
echo " marketing 宣传站 + Flutter Web + 代理(localhost:3000/app/ 路由到 Flutter"
echo ""
echo "数据库命令:"
echo " seed <shop_code> 写入指定门店测试数据(如 S001)"
@@ -139,6 +216,8 @@ show_help() {
}
case "$COMMAND" in
marketing)
;; # 在底部所有函数定义完后执行
run)
case "${2:-}" in
--force) FORCE=true ;;
@@ -223,12 +302,13 @@ esac
cleanup() {
echo ""
info "正在关闭服务..."
if [ -f "$WEB_PID_FILE" ]; then
pid=$(cat "$WEB_PID_FILE")
kill "$pid" 2>/dev/null || true
rm -f "$WEB_PID_FILE"
info "Web 服务已停止"
fi
for pid_file in "$WEB_PID_FILE" "$ELEVENTY_PID_FILE" "$PROXY_PID_FILE"; do
if [ -f "$pid_file" ]; then
pid=$(cat "$pid_file")
kill "$pid" 2>/dev/null || true
rm -f "$pid_file"
fi
done
info "后端继续在后台运行。如需停止:sh scripts/dev.sh stop"
exit 0
}
@@ -284,7 +364,7 @@ wait_backend() {
info "等待后端启动..."
local i=0
while [ $i -lt 30 ]; do
if curl -s -o /dev/null http://localhost:8080/api/v1/auth/login 2>/dev/null; then
if curl -s -o /dev/null http://localhost:8080/health 2>/dev/null; then
success "后端已就绪 → http://localhost:8080"
return 0
fi
@@ -356,6 +436,12 @@ start_web_bg() {
}
# ════════════════════════════════════════════════════════
if [ "$COMMAND" = "marketing" ]; then
cmd_marketing
exit 0
fi
check_deps
if [ "$RUN_BACKEND" = true ]; then