83 lines
2.3 KiB
Dart
83 lines
2.3 KiB
Dart
/// 账号与安全相关领域模型。
|
|
///
|
|
/// 纯 Dart 实体,零 Flutter/UI 依赖(见 AGENTS.md §3)。
|
|
library;
|
|
|
|
/// 登录设备(会话)记录。
|
|
///
|
|
/// 对应「账号与安全 → 登录设备」列表项,展示登录过本账号的终端信息。
|
|
class LoginDevice {
|
|
const LoginDevice({
|
|
required this.id,
|
|
this.deviceName,
|
|
this.deviceModel,
|
|
this.osName,
|
|
this.location,
|
|
this.ip,
|
|
this.lastActiveTime,
|
|
this.current = false,
|
|
});
|
|
|
|
/// 会话唯一标识,用于「下线」操作。
|
|
final String id;
|
|
|
|
final String? deviceName;
|
|
final String? deviceModel;
|
|
final String? osName;
|
|
|
|
/// 登录地点(后台按 IP 解析)。
|
|
final String? location;
|
|
final String? ip;
|
|
|
|
/// 最近活跃时间。
|
|
final String? lastActiveTime;
|
|
|
|
/// 是否为当前设备(当前设备不允许下线)。
|
|
final bool current;
|
|
|
|
/// 列表主标题:优先设备名,其次型号,最后兜底会话 ID。
|
|
String get displayName {
|
|
if (deviceName != null && deviceName!.isNotEmpty) return deviceName!;
|
|
if (deviceModel != null && deviceModel!.isNotEmpty) return deviceModel!;
|
|
return id;
|
|
}
|
|
|
|
factory LoginDevice.fromJson(Map<String, dynamic> json) => LoginDevice(
|
|
id: (json['id'] ?? json['sessionId'] ?? '').toString(),
|
|
deviceName: json['deviceName'] as String?,
|
|
deviceModel: json['deviceModel'] as String?,
|
|
osName: json['osName'] as String?,
|
|
location: json['location'] as String?,
|
|
ip: json['ip'] as String?,
|
|
lastActiveTime: json['lastActiveTime']?.toString(),
|
|
current: json['current'] == true,
|
|
);
|
|
}
|
|
|
|
/// 微信绑定状态。
|
|
class WechatBinding {
|
|
const WechatBinding({
|
|
required this.bound,
|
|
this.nickname,
|
|
this.avatarUrl,
|
|
this.bindTime,
|
|
});
|
|
|
|
/// 是否已绑定微信。
|
|
final bool bound;
|
|
|
|
final String? nickname;
|
|
final String? avatarUrl;
|
|
final String? bindTime;
|
|
|
|
factory WechatBinding.fromJson(Map<String, dynamic> json) => WechatBinding(
|
|
bound: json['bound'] == true,
|
|
nickname: json['nickname'] as String?,
|
|
avatarUrl: json['avatarUrl'] as String?,
|
|
bindTime: json['bindTime']?.toString(),
|
|
);
|
|
|
|
/// 未绑定态的默认值(接口无数据时兜底)。
|
|
static const WechatBinding unbound = WechatBinding(bound: false);
|
|
}
|