refactor(flutter): 重构账号模块并新增配对与独立登录页面
- 将 ApiClient 升级为全局单例,支持完整账号生命周期(登录/注册/刷新/校验/退出) - 新增 TokenResponse / VerifyResponse / BindingItem 数据模型 - 新增 SplashPage 启动登录态检查与 LoginPage 独立登录页 - 新增被控端绑定列表展示、配对码兑换及设备选择功能 - 新增全局 401 拦截器,统一处理令牌失效并跳转登录 - 优化令牌存储策略,对齐 Android 端 TokenStore 行为 - 重构主页面 UI,移除内嵌登录对话框,改用独立页面流程
This commit is contained in:
39
webrtc_controller_flutter/lib/models/verify_response.dart
Normal file
39
webrtc_controller_flutter/lib/models/verify_response.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
/// 令牌校验响应,对应服务端 `GET /api/client/verify`。
|
||||
///
|
||||
/// 与 Android 端 `network/model/VerifyResponse` 字段保持一致。
|
||||
class VerifyResponse {
|
||||
final bool valid;
|
||||
|
||||
/// USER / DEVICE。
|
||||
final String? principalType;
|
||||
final String? principalId;
|
||||
final String? displayName;
|
||||
|
||||
/// 过期时间(秒级时间戳)。
|
||||
final int expiresAt;
|
||||
|
||||
/// 剩余有效秒数。
|
||||
final int remainingSeconds;
|
||||
|
||||
final String? message;
|
||||
|
||||
const VerifyResponse({
|
||||
required this.valid,
|
||||
this.principalType,
|
||||
this.principalId,
|
||||
this.displayName,
|
||||
this.expiresAt = 0,
|
||||
this.remainingSeconds = 0,
|
||||
this.message,
|
||||
});
|
||||
|
||||
factory VerifyResponse.fromJson(Map<String, dynamic> json) => VerifyResponse(
|
||||
valid: json['valid'] == true,
|
||||
principalType: json['principalType'] as String?,
|
||||
principalId: json['principalId'] as String?,
|
||||
displayName: json['displayName'] as String?,
|
||||
expiresAt: (json['expiresAt'] as num?)?.toInt() ?? 0,
|
||||
remainingSeconds: (json['remainingSeconds'] as num?)?.toInt() ?? 0,
|
||||
message: json['message'] as String?,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user