diff --git a/README.md b/README.md index 3129e73..ddf4c34 100644 --- a/README.md +++ b/README.md @@ -1005,8 +1005,16 @@ CLI 中已实现的交互命令包括: ### 13.2 构建与启动 +> **Windows 用户注意:** Windows 默认不包含 `make` 命令。你可以通过以下方式之一来构建: +> +> - 直接使用下方 "Windows(PowerShell)" 对应的手动命令(无需额外安装) +> - 安装 make:`choco install make`(Chocolatey)或 `scoop install make`(Scoop) +> - 在 Git Bash / WSL 中运行 `bash build.sh` 或 `make` + **构建(包含前端):** +Linux / macOS: + ```bash # 使用 Makefile(推荐) make build @@ -1016,6 +1024,16 @@ cd web && npm install && npm run build cargo build --release ``` +Windows(PowerShell): + +```powershell +# 安装前端依赖并构建 +cd web; npm install; npm run build; cd .. + +# 构建 Rust 后端 +cargo build --release +``` + 构建产物: - 前端输出到 `static/` 目录 - 编译时通过 `rust-embed` 嵌入二进制文件 @@ -1023,6 +1041,8 @@ cargo build --release **启动网关:** +Linux / macOS: + ```bash # 生产模式(使用嵌入的前端) cargo run --release -- gateway @@ -1032,6 +1052,30 @@ cd web && npm run dev & STATIC_DIR=static cargo run -- gateway ``` +Windows(PowerShell): + +```powershell +# 生产模式(使用嵌入的前端) +cargo run --release -- gateway + +# 开发模式(使用磁盘文件,支持前端热更新,需要开两个终端) +# 终端1:启动前端开发服务器 +cd web; npm run dev +# 终端2:启动网关 +$env:STATIC_DIR="static"; cargo run -- gateway +``` + +**常用 Makefile 命令对照:** + +| Makefile 命令 | Linux / macOS | Windows(PowerShell) | +|------|------|------| +| `make install` | `cd web && npm install` | `cd web; npm install` | +| `make dev-backend` | `cargo run -- gateway` | `cargo run -- gateway` | +| `make dev-frontend` | `cd web && npm run dev` | `cd web; npm run dev` | +| `make build` | `cd web && npm run build && cargo build --release` | `cd web; npm run build; cd ..; cargo build --release` | +| `make run` | `cargo run --release -- gateway` | `cargo run --release -- gateway` | +| `make check` | `cd web && npm run build && cargo check && cargo clippy` | `cd web; npm run build; cd ..; cargo check; cargo clippy` | + ### 13.3 启动本地 CLI ```bash