feat: 更新 README.md,添加 Windows 用户构建与启动指南,提供 Makefile 命令对照

This commit is contained in:
oudecheng 2026-06-08 11:07:36 +08:00
parent e4bc8153a0
commit 2fbe5bdde1

View File

@ -1005,8 +1005,16 @@ CLI 中已实现的交互命令包括:
### 13.2 构建与启动
> **Windows 用户注意:** Windows 默认不包含 `make` 命令。你可以通过以下方式之一来构建:
>
> - 直接使用下方 "WindowsPowerShell" 对应的手动命令(无需额外安装)
> - 安装 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
```
WindowsPowerShell
```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
```
WindowsPowerShell
```powershell
# 生产模式(使用嵌入的前端)
cargo run --release -- gateway
# 开发模式(使用磁盘文件,支持前端热更新,需要开两个终端)
# 终端1启动前端开发服务器
cd web; npm run dev
# 终端2启动网关
$env:STATIC_DIR="static"; cargo run -- gateway
```
**常用 Makefile 命令对照:**
| Makefile 命令 | Linux / macOS | WindowsPowerShell |
|------|------|------|
| `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