chore: 初始化脚手架 — sunny_mochi 企业级 Flutter 模板

Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库
7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系
5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter

通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
This commit is contained in:
SkyJourney
2026-05-14 12:51:05 +08:00
commit 61017f1c39
204 changed files with 15386 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
/// 服务端业务错误码常量。
///
/// envelope 结构:`{retCode: String, retMsg: String, retData: T?}`key map: code/msg/data
/// 错误码格式:`A04XX` = 客户端错 / `A05XX` = 服务端错 / `99999` = 兜底 / `00000` = 成功
abstract class ResponseCode {
/// 成功
static const String success = '00000';
/// 兜底请求失败
static const String generic = '99999';
/// 服务端 500 类
static const String serverError = 'A0500';
static const String systemError = 'A0501';
/// 客户端 400 类
static const String paramError = 'A0400';
static const String paramMissing = 'A0402';
static const String resourceNotFound = 'A0404';
/// 鉴权过期 → 跳登录
static const String unauthorized = 'A0401';
/// Token 类业务码(占位 — 待后端确认实际值后改这里一处)。
// TODO: 后端确认后更新 tokenExpired / tokenInvalid 实际字符串值
static const String tokenExpired = 'TOKEN_EXPIRED';
static const String tokenInvalid = 'TOKEN_INVALID';
/// 仅 token 类业务码才允许 TokenRefreshInterceptor 触发 refresh。
static bool isTokenRefreshable(String? code) =>
code == unauthorized || code == tokenExpired || code == tokenInvalid;
static bool isSuccess(String? code) => code == success;
static bool isUnauthorized(String? code) => code == unauthorized;
/// 用户友好的错误提示。
static String friendlyMessage(String? code, String fallback) {
return switch (code) {
success => '',
unauthorized => '登录已过期,请重新登录',
paramError => '请求参数有误,请稍候重试',
paramMissing => '请求参数不完整,请稍候重试',
resourceNotFound => '请求的资源不存在',
serverError || systemError => '服务器开小差啦,请稍候重试',
generic => '请求失败',
_ => fallback,
};
}
}