From e5dd26719b30a7b7c1a9bf0d9538a23d162b0d18 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Tue, 21 Jul 2026 21:37:03 +0800 Subject: [PATCH] docs: fix setup command paths --- README.md | 30 ++++++++++++++++++++---------- docs/mvp-verification.md | 34 +++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 566acc0..9c73595 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,11 @@ Web 客户端桌面优先,同时保留移动浏览器可用性;登录页允 ### 2. 启动 PostgreSQL -在仓库根目录运行: +在任意仓库子目录运行: ```powershell +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location $repoRoot docker compose -f infra/docker-compose.yml up -d ``` @@ -62,7 +64,8 @@ Compose 只用于本地开发,创建 PostgreSQL 16 服务并监听 `localhost: ### 3. 初始化演示数据 ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go run ./cmd/seed ``` @@ -73,7 +76,8 @@ go run ./cmd/seed 在新的终端中运行: ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go run ./cmd/api ``` @@ -84,12 +88,13 @@ go run ./cmd/api 在新的终端中运行: ```powershell -Set-Location apps/web_v1 +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/web_v1') npm ci npm run dev ``` -Vite 默认地址为 `http://localhost:5173`。登录时服务器地址填写 `http://localhost:9150`;也可以通过 `VITE_API_BASE_URL` 指定 Web 的初始 API 地址。 +Vite 默认地址为 `http://localhost:5173`。登录页的服务器地址默认是 `http://localhost:9150`;用户可以改为私有部署服务器的 IP 地址或域名,登录及后续 API 请求会使用用户填写的地址。 ## 配置 @@ -144,14 +149,16 @@ Vite 默认地址为 `http://localhost:5173`。登录时服务器地址填写 `h 后端: ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go test ./... ``` Web: ```powershell -Set-Location apps/web_v1 +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/web_v1') node scripts/visual-check.mjs npm run build npm run lint @@ -160,7 +167,8 @@ npm run lint 如果设置了指向隔离测试库的 `DATABASE_URL`,再运行 PostgreSQL 集成检查: ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go test -tags integration ./internal/models -run TestPostgresPing -v ``` @@ -171,7 +179,8 @@ go test -tags integration ./internal/models -run TestPostgresPing -v 先完成 Web 依赖安装,再构建 Tauri 可执行文件: ```powershell -Set-Location apps/desktop +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/desktop') npm ci npm run build ``` @@ -181,7 +190,8 @@ npm run build 需要安装包时运行: ```powershell -Set-Location apps/desktop +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/desktop') npm run bundle ``` diff --git a/docs/mvp-verification.md b/docs/mvp-verification.md index a76ab8f..633829c 100644 --- a/docs/mvp-verification.md +++ b/docs/mvp-verification.md @@ -37,9 +37,11 @@ ### PostgreSQL -需要 Docker Desktop。仓库根目录的预期命令是: +需要 Docker Desktop。可在任意仓库子目录运行: ```powershell +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location $repoRoot docker compose -f infra/docker-compose.yml up -d docker compose -f infra/docker-compose.yml ps ``` @@ -51,12 +53,14 @@ docker compose -f infra/docker-compose.yml ps 数据库可用后,在两个独立终端中运行: ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go run ./cmd/seed ``` ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go run ./cmd/api ``` @@ -72,7 +76,8 @@ Invoke-RestMethod http://localhost:9150/api/v1/status ### Web 开发服务器 ```powershell -Set-Location apps/web_v1 +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/web_v1') npm ci npm run dev ``` @@ -84,13 +89,16 @@ npm run dev ### 后端 ```powershell -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go test ./... ``` 本次退出 `0`。为排除 Go 测试缓存影响,还执行了: ```powershell +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') go test -count=1 ./... ``` @@ -101,8 +109,9 @@ go test -count=1 ./... 仅在准备了隔离的实时测试数据库时运行: ```powershell -$env:DATABASE_URL='<隔离测试库连接串>' -Set-Location backend +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'backend') +$env:DATABASE_URL = '<隔离测试库连接串>' go test -tags integration ./internal/models -run TestPostgresPing -v ``` @@ -111,7 +120,8 @@ go test -tags integration ./internal/models -run TestPostgresPing -v ### Web ```powershell -Set-Location apps/web_v1 +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/web_v1') node scripts/visual-check.mjs npm run build npm run lint @@ -144,7 +154,8 @@ node scripts/structure-check.mjs ### 桌面端 ```powershell -Set-Location apps/desktop +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/desktop') npm ci npm run build ``` @@ -160,7 +171,8 @@ apps/desktop/src-tauri/target/release/senlinai_workbench.exe 安装包是独立验证项: ```powershell -Set-Location apps/desktop +$repoRoot = (git rev-parse --show-toplevel).Trim() +Set-Location (Join-Path $repoRoot 'apps/desktop') npm run bundle ``` @@ -210,4 +222,4 @@ npm run bundle ## 文档一致性检查 -已对两份文档执行旧品牌、旧 API 前缀、旧前端目录和旧技术栈关键词扫描,结果无匹配。还应抽查 Markdown 相对链接存在,所有命令的工作目录与仓库实际脚本一致。 +已完成以下一致性检查:两份文档中的旧品牌、旧 API 前缀、旧前端目录和旧技术栈关键词扫描无匹配;Markdown 相对链接均指向现有文件;命令使用的工作目录、入口和脚本均与仓库实际路径一致。