feat: Week 4 收尾 + 架构治理 — 搜索/家长中心/Feature Flag/Docker/环境配置
架构治理: - Feature Flag 落地: Cargo.toml [features] default=["diary"] + main.rs cfg 条件编译 - 环境配置统一: AppConfig 类 + --dart-define 注入 + SSE 端口 8080→3000 修复 搜索替代方案 (无 FTS): - SearchBloc + 标签/心情筛选接入后端 API - JournalRepository 扩展 mood/tag 筛选参数 - 搜索页 UI 接入实际数据(替换占位文本) 家长中心最小集 (PIPL 合规): - 后端: parent_service (绑定/查看/导出/删除/解绑) + parent_handler (6 个 API 端点) - 前端: ParentBloc + ParentPage 功能完整实现 - 绑定孩子、只读查看日记、导出数据、删除数据、解绑 Docker 部署: - verify.sh 健康检查脚本 (Axum/PG/Redis/OpenAPI 四项检查) 测试修复: - home_bloc_test / calendar_bloc_test 适配 JournalRepository 新参数 验证: flutter test 84/84 pass, cargo test 76/76 pass, cargo check pass
This commit is contained in:
48
app/lib/config/app_config.dart
Normal file
48
app/lib/config/app_config.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
// 应用环境配置 — 通过 --dart-define 注入
|
||||
//
|
||||
// 使用方式:
|
||||
// flutter run --dart-define=API_BASE_URL=http://localhost:3000/api/v1
|
||||
// flutter run --dart-define=API_BASE_URL=https://api.nuanji.app/api/v1
|
||||
|
||||
/// 应用环境配置 — 集中管理所有外部服务地址
|
||||
class AppConfig {
|
||||
/// API 基础 URL(后端 Axum 服务地址)
|
||||
final String apiBaseUrl;
|
||||
|
||||
/// SSE 推送服务 URL(通常与 API 同一地址)
|
||||
final String sseBaseUrl;
|
||||
|
||||
const AppConfig({
|
||||
required this.apiBaseUrl,
|
||||
required this.sseBaseUrl,
|
||||
});
|
||||
|
||||
/// 从编译时环境变量构建配置
|
||||
///
|
||||
/// 使用 `--dart-define` 注入,未设置时使用默认值。
|
||||
factory AppConfig.fromEnvironment({
|
||||
String defaultApiBaseUrl = 'http://localhost:3000/api/v1',
|
||||
String defaultSseBaseUrl = 'http://localhost:3000/api/v1',
|
||||
}) {
|
||||
// const String.fromEnvironment 在编译时求值
|
||||
const apiBaseUrl = String.fromEnvironment(
|
||||
'API_BASE_URL',
|
||||
defaultValue: 'http://localhost:3000/api/v1',
|
||||
);
|
||||
const sseBaseUrl = String.fromEnvironment(
|
||||
'SSE_BASE_URL',
|
||||
defaultValue: 'http://localhost:3000/api/v1',
|
||||
);
|
||||
|
||||
return AppConfig(
|
||||
apiBaseUrl: apiBaseUrl,
|
||||
sseBaseUrl: sseBaseUrl,
|
||||
);
|
||||
}
|
||||
|
||||
/// 开发环境默认配置
|
||||
static const dev = AppConfig(
|
||||
apiBaseUrl: 'http://localhost:3000/api/v1',
|
||||
sseBaseUrl: 'http://localhost:3000/api/v1',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user