From 2fbe5bdde19d7d232ca2e415d7dc54115aef760e Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Mon, 8 Jun 2026 11:07:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20README.md=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Windows=20=E7=94=A8=E6=88=B7=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E4=B8=8E=E5=90=AF=E5=8A=A8=E6=8C=87=E5=8D=97=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=20Makefile=20=E5=91=BD=E4=BB=A4=E5=AF=B9?= =?UTF-8?q?=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) 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