Files
hms/scripts/mpsync.ps1
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

63 lines
2.5 KiB
PowerShell

# 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
}