diff --git a/.cursor/rules/jiang13-bbs-local-dev.mdc b/.cursor/rules/jiang13-bbs-local-dev.mdc index 83072fd..bec1d0a 100644 --- a/.cursor/rules/jiang13-bbs-local-dev.mdc +++ b/.cursor/rules/jiang13-bbs-local-dev.mdc @@ -57,6 +57,10 @@ npm.cmd run dev 双击 / 运行仓库根 `stop.bat`(或 `./stop.sh`)即可,无需开任务管理器。 +### Windows `.bat` 编码 + +`cmd.exe` 按系统 ANSI(中文 Windows 多为 GBK)解析 `.bat`,**禁止**在 `.bat` 里写 UTF-8 中文(会乱码断行,出现 `'/' 不是内部或外部命令`)。`.bat` 保持 ASCII;中文提示放 `stop.ps1`(UTF-8 BOM)或英文。 + ## 遗留目录 `backend/cmd/jiang13/data/` 是错误 cwd 的产物,禁止当数据源。发现后把 `uploads/` 合并进 `backend/data/uploads/`,再删遗留目录。 diff --git a/stop.bat b/stop.bat index 3afa70c..6bef9c1 100644 --- a/stop.bat +++ b/stop.bat @@ -1,21 +1,19 @@ @echo off +REM ASCII-only: cmd.exe on Chinese Windows misparses UTF-8 .bat as GBK and breaks lines. title jiang13-bbs stopper echo ============================================ echo jiang13-bbs Dev Stopper echo ============================================ echo. -echo 按端口终止监听进程树(:3000 前端 / :3001 后端)... -echo. -REM 仅关 Cursor 终端 / Ctrl+C 往往杀不掉 go run / node 的子进程; -REM 此处按 Listen 端口取 OwningProcess,再 taskkill /T 杀整棵树。 powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0stop.ps1" if errorlevel 1 ( - echo [WARN] stop.ps1 执行异常,可手动:taskkill /T /F /PID ^ + echo [WARN] stop.ps1 failed. Manual: taskkill /T /F /PID ^ + pause + exit /b 1 ) echo. -echo [OK] 端口清理完成。 -echo PostgreSQL(Docker)未动;若要停库:docker compose down +echo [OK] Done. Postgres untouched; stop DB with: docker compose down echo ============================================ pause diff --git a/stop.ps1 b/stop.ps1 index b8989c4..ec56817 100644 --- a/stop.ps1 +++ b/stop.ps1 @@ -1,11 +1,15 @@ -# 按 Listen 端口终止进程树(含子进程)。默认 :3000 前端 / :3001 后端。 -# 由 stop.bat 调用;也可直接:powershell -File stop.ps1 +# Kill process trees listening on given ports. Default: :3000 frontend / :3001 backend. +# Called by stop.bat; or: powershell -File stop.ps1 param( [int[]]$Ports = @(3000, 3001) ) $ErrorActionPreference = 'SilentlyContinue' +[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + +Write-Host "Stopping listeners on :3000 / :3001 (process trees)..." +Write-Host "" foreach ($port in $Ports) { $pids = @( @@ -13,12 +17,15 @@ foreach ($port in $Ports) { Select-Object -ExpandProperty OwningProcess -Unique ) if (-not $pids -or $pids.Count -eq 0) { - Write-Host " :$port 空闲" + Write-Host " :$port idle" continue } foreach ($procId in $pids) { if ($procId -le 0) { continue } - Write-Host " :$port -> PID $procId (含子进程)" + Write-Host " :$port -> PID $procId (tree)" & taskkill.exe /T /F /PID $procId | Out-Null } } + +Write-Host "" +Write-Host "Port cleanup finished." \ No newline at end of file