/// 认证领域实体。 /// /// 以不可变类表达,避免 UI / 仓库直接依赖后台 DTO 结构。 /// 因未运行 build_runner(避免改动依赖与生成产物),此处手写等价实现: /// 所有字段 final、提供 const 构造与 copyWith,并手动实现 JSON 转换。 class LoginResult { const LoginResult({ required this.token, this.refreshToken, this.userId, this.phone, }); final String token; final String? refreshToken; final String? userId; final String? phone; LoginResult copyWith({ String? token, String? refreshToken, String? userId, String? phone, }) { return LoginResult( token: token ?? this.token, refreshToken: refreshToken ?? this.refreshToken, userId: userId ?? this.userId, phone: phone ?? this.phone, ); } factory LoginResult.fromJson(Map json) { // 后端 C 端(open 模块)返回 AuthenticationToken:{ tokenType, accessToken, refreshToken, expiresIn }。 // 兼容旧字段 token(部分场景/历史返回),优先读取 accessToken。 return LoginResult( token: (json['accessToken'] ?? json['token']) as String, refreshToken: json['refreshToken'] as String?, userId: json['userId'] as String?, phone: json['phone'] as String?, ); } } /// 发送短信验证码的用途。 enum SmsScene { login, register, resetPassword, }