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 默认关闭域名校验
This commit is contained in:
62
scripts/mpsync.ps1
Normal file
62
scripts/mpsync.ps1
Normal file
@@ -0,0 +1,62 @@
|
||||
# MPSync — auto clean stale DevTools + open automation port
|
||||
# Usage: powershell -File scripts/mpsync.ps1 [-Build]
|
||||
param([switch]$Build)
|
||||
|
||||
$Port = 9420
|
||||
|
||||
Write-Host "[MPSync] Step 1: Kill stale DevTools processes..." -ForegroundColor Cyan
|
||||
$procs = Get-Process -Name "wechatdevtools" -ErrorAction SilentlyContinue
|
||||
if ($null -ne $procs) {
|
||||
Write-Host "[MPSync] Found $($procs.Count) stale processes, killing..." -ForegroundColor Yellow
|
||||
Stop-Process -Name "wechatdevtools" -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 5
|
||||
$left = Get-Process -Name "wechatdevtools" -ErrorAction SilentlyContinue
|
||||
if ($null -ne $left) {
|
||||
Write-Host "[MPSync] Still $($left.Count) remaining, second attempt..." -ForegroundColor Yellow
|
||||
Stop-Process -Name "wechatdevtools" -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
Write-Host "[MPSync] Cleanup done" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[MPSync] No stale processes" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
# Optional build
|
||||
if ($Build) {
|
||||
Write-Host "[MPSync] Building miniprogram..." -ForegroundColor Cyan
|
||||
Set-Location "G:\hms\apps\miniprogram"
|
||||
pnpm build:weapp 2>&1 | Select-Object -Last 3
|
||||
Write-Host "[MPSync] Build done" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Open DevTools with project
|
||||
$DevToolsExe = "D:\微信web开发者工具\微信web开发者工具.exe"
|
||||
$DistPath = "G:\hms\apps\miniprogram\dist"
|
||||
|
||||
$running = Get-Process -Name "wechatdevtools" -ErrorAction SilentlyContinue
|
||||
if ($null -eq $running) {
|
||||
Write-Host "[MPSync] Starting DevTools..." -ForegroundColor Cyan
|
||||
Start-Process $DevToolsExe -ArgumentList $DistPath
|
||||
Write-Host "[MPSync] Waiting for DevTools to initialize..." -ForegroundColor Cyan
|
||||
Start-Sleep -Seconds 15
|
||||
} else {
|
||||
Write-Host "[MPSync] DevTools already running ($($running.Count) processes)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Open automation port via CLI
|
||||
Write-Host "[MPSync] Opening automation port $Port..." -ForegroundColor Cyan
|
||||
$cliShort = (New-Object -ComObject Scripting.FileSystemObject).GetFile("D:\微信web开发者工具\cli.bat").ShortPath
|
||||
$cliResult = & $cliShort auto --project $DistPath --auto-port $Port 2>&1
|
||||
$cliResult | ForEach-Object { Write-Host $_ }
|
||||
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
# Verify port
|
||||
$listener = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue
|
||||
if ($null -ne $listener) {
|
||||
Write-Host "[MPSync] Port $Port is listening - ready for MCP" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[MPSync] WARNING: Port $Port not listening yet" -ForegroundColor Yellow
|
||||
}
|
||||
77
scripts/mpsync.sh
Normal file
77
scripts/mpsync.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user