Files
Ichino/lib/models/user_preview.dart
T
Cookiues 44c4a1daae feat: 连接信息恢复的会话在 isLogin 时直接开放票据与风险功能
- 恢复时除了 GetUserDataApi 再拉一次 GetUserPreviewApi:服务器说 isLogin 为 true
  就把这次会话当已登录,_gameLogin 落地,票据与风险页按「登录后 60 秒冷却」计时
  (loginDateTime 取恢复当下),不必再发一次 UserLoginApi
- GetUserPreviewApi 的响应里没有 loginId,而 UpsertUserAll 要拿它当 playlogId,
  所以导出连接信息时把本机的 loginId 一起带过去,恢复端优先用这个值,
  拉不到才退回 preview 里的字段(多半是 0)
- 只有 Cookie、preview 拉不到、或服务器说没在登录中时仍按只读处理,
  提示横幅与 SnackBar 文案区分「可写」和「只能读」两种恢复结果
- HomePage 的恢复入口收成 restored: SessionRestoreResult?,把 preview 与
  userData 一起当种子,省掉两次重复请求
2026-09-29 13:47:03 +08:00

97 lines
2.9 KiB
Dart

class UserPreviewDataBean {
final int userId;
final String userName;
final bool isLogin;
/// 机台侧这次登录的 `loginId`(组装 UpsertUserAll 时当 playlogId 用)。
/// 服务器没带这个字段时是 0。
final int loginId;
final String lastGameId;
final String lastRomVersion;
final String lastDataVersion;
final String lastLoginDate;
final String lastPlayDate;
final int playerRating;
final int nameplateId;
final int iconId;
final int trophyId;
final bool isNetMember;
final bool isInherit;
final int totalAwake;
final int dispRate;
final String dailyBonusDate;
final int headPhoneVolume;
final int banState;
final int errorId;
const UserPreviewDataBean({
required this.userId,
required this.userName,
required this.isLogin,
this.loginId = 0,
required this.lastGameId,
required this.lastRomVersion,
required this.lastDataVersion,
required this.lastLoginDate,
required this.lastPlayDate,
required this.playerRating,
required this.nameplateId,
required this.iconId,
required this.trophyId,
required this.isNetMember,
required this.isInherit,
required this.totalAwake,
required this.dispRate,
required this.dailyBonusDate,
required this.headPhoneVolume,
required this.banState,
required this.errorId,
});
factory UserPreviewDataBean.fromJson(Map<String, dynamic> json) {
int toInt(dynamic v) {
if (v == null) return 0;
if (v is int) return v;
if (v is String) return int.tryParse(v) ?? 0;
if (v is double) return v.toInt();
return 0;
}
bool toBool(dynamic v) {
if (v == null) return false;
if (v is bool) return v;
if (v is int) return v != 0;
if (v is String) return v == '1' || v.toLowerCase() == 'true';
return false;
}
String toStr(dynamic v) => v?.toString() ?? '';
return UserPreviewDataBean(
userId: toInt(json['userId']),
userName: toStr(json['userName']),
isLogin: toBool(json['isLogin']),
loginId: toInt(json['loginId']),
lastGameId: toStr(json['lastGameId']),
lastRomVersion: toStr(json['lastRomVersion']),
lastDataVersion: toStr(json['lastDataVersion']),
lastLoginDate: toStr(json['lastLoginDate']),
lastPlayDate: toStr(json['lastPlayDate']),
playerRating: toInt(json['playerRating']),
nameplateId: toInt(json['nameplateId']),
iconId: toInt(json['iconId']),
trophyId: toInt(json['trophyId']),
isNetMember: toBool(json['isNetMember']),
isInherit: toBool(json['isInherit']),
totalAwake: toInt(json['totalAwake']),
dispRate: toInt(json['dispRate']),
dailyBonusDate: toStr(json['dailyBonusDate']),
headPhoneVolume: (json['headPhoneVolume'] is String)
? (int.tryParse(json['headPhoneVolume']) ?? 0)
: toInt(json['headPhoneVolume']),
banState: toInt(json['banState']),
errorId: toInt(json['errorId']),
);
}
}