feat: 实现后端多环境配置机制

- 使用 toml crate 替代 config crate 直接读取配置文件
- 创建 config/default.toml、config/development.toml、config/production.toml
- 重写 config.rs 支持多环境配置加载
- 增强 deploy.sh 支持 development/production 环境参数
- 更新 IMPROVEMENTS.md 标记环境区分完成
This commit is contained in:
2026-04-17 11:11:13 +08:00
parent ca7ddcc55e
commit da4e6f557e
8 changed files with 314 additions and 62 deletions

View File

@@ -538,6 +538,28 @@ fi
- 本改进与"前后端版本统一管理"(改进路线图 P1可合并实施
- 本改进与"拆分 main.rs 路由处理器"(改进路线图 P1有协同效应
### 实施结果
✅ **已完成** (2026-04-17)
**实际实施方案**:采用简化方案 + TOML 配置文件
| 改动项 | 说明 |
|--------|------|
| `config.rs` | 重写为使用 `toml` crate 直接读取配置文件 |
| `config/*.toml` | 创建 `default.toml`、`development.toml`、`production.toml` |
| `Cargo.toml` | 添加 `toml = "0.8"` 依赖,移除 `config = "0.14"` |
| `deploy.sh` | 重写支持 `development`/`production` 环境参数 |
| systemd service | 创建 `rust-backend-dev.service` 测试服务 |
**关键修复**
- TOML 文件去掉 `[development]` 等 section 头config crate 遗留语法)
- `database_url` 使用 `127.0.0.1` 而非 `localhost`Docker PostgreSQL 监听地址)
**测试验证**
- 测试服务运行在端口 8080
- Nginx 代理 `https://xmclassmate.top/dev/api/login` 正常工作
---
## 十二、付费功能系统
@@ -732,5 +754,5 @@ pages/
---
**最后更新**2026-04-14
**最后更新**2026-04-17
**维护者**milky