Initial project
This commit is contained in:
31
apps/im_app/lib/core/foundation/api_paths.dart
Normal file
31
apps/im_app/lib/core/foundation/api_paths.dart
Normal 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';
|
||||
}
|
||||
14
apps/im_app/lib/core/foundation/config.dart
Normal file
14
apps/im_app/lib/core/foundation/config.dart
Normal 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;
|
||||
}
|
||||
17
apps/im_app/lib/core/foundation/constants.dart
Normal file
17
apps/im_app/lib/core/foundation/constants.dart
Normal 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);
|
||||
}
|
||||
0
apps/im_app/lib/core/foundation/errors.dart
Normal file
0
apps/im_app/lib/core/foundation/errors.dart
Normal file
0
apps/im_app/lib/core/foundation/extensions.dart
Normal file
0
apps/im_app/lib/core/foundation/extensions.dart
Normal file
0
apps/im_app/lib/core/foundation/logger.dart
Normal file
0
apps/im_app/lib/core/foundation/logger.dart
Normal file
0
apps/im_app/lib/core/foundation/types.dart
Normal file
0
apps/im_app/lib/core/foundation/types.dart
Normal file
0
apps/im_app/lib/core/foundation/utils.dart
Normal file
0
apps/im_app/lib/core/foundation/utils.dart
Normal file
Reference in New Issue
Block a user