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