Files
hms/scripts/mpsync.sh
iven 085163ec7a
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
feat(miniprogram): 访客模式 + 长辈模式 + MCP 自动化脚本
访客模式:
- 未登录用户可见首页(轮播图+健康资讯+登录引导)和"我的"页面
- 健康和消息 tab 显示 GuestGuard 登录拦截
- 登录页增加"暂不登录,先看看"跳过入口
- 401 拦截器增加 hasToken 检查,避免访客被重定向到登录页
- 退出登录后 reLaunch 到首页而非登录页

长辈模式:
- 新增 stores/ui.ts 管理显示模式(标准/长辈)
- 长辈模式放大字体 ×1.3、间距 ×1.2、按钮加大
- "我的 → 账号 → 长辈模式"切换页
- 设置持久化到 Storage

修复:
- Health/Messages 页面 Hooks 顺序违规(条件 return 在 hooks 之间)
  导致访客模式下页面白屏,所有 hooks 移到条件判断之前

工程:
- scripts/mpsync.sh/ps1 自动清理残留 DevTools 进程
- project.config.json 默认关闭域名校验
2026-05-09 11:42:44 +08:00

78 lines
2.3 KiB
Bash

#!/bin/bash
# MPSync — 微信开发者工具 MCP 自动化前置脚本
# 清理残留进程 + 重新开启自动化端口
# 用法: bash scripts/mpsync.sh [-b|--build]
CLI="/d/微信web开发者工具/cli.bat"
DIST="G:/hms/apps/miniprogram/dist"
PORT=9420
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
status() { echo -e "${CYAN}[MPSync]${NC} $1"; }
ok() { echo -e "${GREEN}[MPSync]${NC} $1"; }
warn() { echo -e "${YELLOW}[MPSync]${NC} $1"; }
# Step 1: Kill stale DevTools processes
status "Step 1: Killing stale DevTools processes..."
count=$(tasklist 2>/dev/null | grep -c "wechatdevtools.exe" | tr -d '\r\n' || echo "0")
if [ "$count" -gt 0 ]; then
warn "Found $count stale processes, killing..."
cmd.exe /C "taskkill /F /IM wechatdevtools.exe /T" > /dev/null 2>&1
sleep 5
count2=$(tasklist 2>/dev/null | grep -c "wechatdevtools.exe" | tr -d '\r\n' || echo "0")
if [ "$count2" -gt 0 ]; then
warn "Still $count2 remaining, second attempt..."
cmd.exe /C "taskkill /F /IM wechatdevtools.exe /T" > /dev/null 2>&1
sleep 3
fi
ok "Cleanup done"
else
ok "No stale processes"
fi
sleep 2
# Step 2: Optional build
if [ "$1" = "-b" ] || [ "$1" = "--build" ]; then
status "Building miniprogram..."
cd "G:/hms/apps/miniprogram" && pnpm build:weapp 2>&1 | tail -3
ok "Build done"
fi
# Step 3: Start DevTools if not running
running=$(tasklist 2>/dev/null | grep -c "wechatdevtools.exe" | tr -d '\r\n' || echo "0")
if [ "$running" -eq 0 ]; then
status "Starting DevTools..."
# 找到可执行文件
EXE=$(find "/d/微信web开发者工具" -maxdepth 1 -name "*.exe" 2>/dev/null | head -1)
if [ -n "$EXE" ]; then
"$EXE" "$DIST" &
status "Waiting for DevTools to initialize (15s)..."
sleep 15
else
warn "Cannot find DevTools exe, please open manually"
fi
else
ok "DevTools already running ($running processes)"
fi
# Step 4: Open automation port
status "Opening automation port $PORT..."
"$CLI" auto --project "$DIST" --auto-port $PORT 2>&1
sleep 3
# Step 5: Verify
listening=$(netstat -ano 2>/dev/null | grep ":${PORT}.*LISTEN" | head -1)
if [ -n "$listening" ]; then
ok "Port $PORT is listening — ready for MCP"
else
warn "Port $PORT not listening yet, wait a moment..."
fi