Initial project

This commit is contained in:
Cody
2026-03-06 14:56:17 +08:00
parent 977b627b15
commit bf9e099747
1180 changed files with 50973 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/// API 路径常量 — 全局统一管理
///
/// 所有 HTTP 接口路径在此定义,`@ApiRequest(path: ApiPaths.xxx)` 引用。
/// 集中管理便于:搜索、重命名、接口迁移、后端对齐。
///
/// 命名规则:`模块_操作`,如 `authLogin`、`chatSendMessage`。
///
/// 新增路径时,先 Cmd+F 搜索路径值,确认不重复后再添加。
// ignore: avoid_classes_with_only_static_members
class ApiPaths {
ApiPaths._();
// ── Auth ──
static const authLogin = '/auth/login';
static const authRefreshToken = '/auth/refresh-token';
static const authLogout = '/auth/logout';
// ── User ──
static const userProfile = '/user/profile';
static const userUpdateProfile = '/user/update-profile';
// ── Chat ──
static const chatSendMessage = '/chat/send-message';
static const chatHistory = '/chat/history';
// ── Upload ──
static const uploadFile = '/upload/file';
// ── WebSocket ──
static const wsConnect = '/ws';
}

View File

@@ -0,0 +1,14 @@
// 编译期从 --dart-define-from-file=config/config.json 注入
// CI 打包时脚本修改 config.json 写入线上值本地开发保持默认IS_DEV=true
// ignore: avoid_classes_with_only_static_members
class AppConfig {
AppConfig._();
static const isDev = bool.fromEnvironment('IS_DEV', defaultValue: true);
static const apiBaseUrl = String.fromEnvironment(
'API_BASE_URL',
defaultValue: 'https://dev-api.example.com',
);
static bool get isProd => !isDev;
}

View File

@@ -0,0 +1,17 @@
/// 全局常量
///
/// 跨模块共用的配置值集中管理,避免散落在各处导致不一致。
class AppConstants {
AppConstants._();
// ── 网络重试 ──
/// 最大重试次数HTTP 瞬态错误 + WebSocket 重连 统一)
static const maxRetries = 3;
/// 重试基础延迟(指数退避起点)
static const retryBaseDelay = Duration(seconds: 1);
/// 重连最大延迟(指数退避上限)
static const maxReconnectDelay = Duration(seconds: 30);
}