0419 0318
更新4
This commit is contained in:
@@ -34,7 +34,7 @@ class _UserPageState extends State<UserPage> {
|
||||
Future<void> _loadRadarData() async {
|
||||
final provider = Provider.of<UserProvider>(context, listen: false);
|
||||
try {
|
||||
final data = await provider.fetchRadarData("684a6ee7f62aed83538ded34");
|
||||
final data = await provider.fetchRadarData(provider.user?.id ?? 'default_id');
|
||||
setState(() {
|
||||
_radarData = data;
|
||||
});
|
||||
@@ -648,6 +648,123 @@ class _UserPageState extends State<UserPage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 移除 Sega 账号
|
||||
Future<void> _removeSegaCard(SegaCard card, UserModel user) async {
|
||||
final confirm = await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text("确认移除"),
|
||||
content: Text("确定要删除 ${card.segaId} 吗?"),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text("取消")),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
child: const Text("删除"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirm != true) return;
|
||||
|
||||
final provider = Provider.of<UserProvider>(context, listen: false);
|
||||
|
||||
// 直接删除,不使用 copyWith
|
||||
List<SegaCard> newList = List.from(user.segaCards ?? [])..remove(card);
|
||||
|
||||
// 完全沿用你原来的 UserModel 构造方式
|
||||
UserModel updatedUser = UserModel(
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
userId: user.userId,
|
||||
teamId: user.teamId,
|
||||
email: user.email,
|
||||
password: user.password,
|
||||
twoFactorKey: user.twoFactorKey,
|
||||
apiKey: user.apiKey,
|
||||
apiBindKey: user.apiBindKey,
|
||||
protectRole: user.protectRole,
|
||||
risks: user.risks,
|
||||
mcName: user.mcName,
|
||||
userName2userId: user.userName2userId,
|
||||
lxKey: user.lxKey,
|
||||
dfUsername: user.dfUsername,
|
||||
dfPassword: user.dfPassword,
|
||||
nuoId: user.nuoId,
|
||||
botId: user.botId,
|
||||
spasolBotId: user.spasolBotId,
|
||||
githubId: user.githubId,
|
||||
rating: user.rating,
|
||||
ratingMax: user.ratingMax,
|
||||
iconId: user.iconId,
|
||||
plateId: user.plateId,
|
||||
plateIds: user.plateIds,
|
||||
frameId: user.frameId,
|
||||
charaSlots: user.charaSlots,
|
||||
qiandaoDay: user.qiandaoDay,
|
||||
inviter: user.inviter,
|
||||
successLogoutTime: user.successLogoutTime,
|
||||
lastLoginTime: user.lastLoginTime,
|
||||
friendIds: user.friendIds,
|
||||
bio: user.bio,
|
||||
friendBio: user.friendBio,
|
||||
sex: user.sex,
|
||||
isDisagreeRecommend: user.isDisagreeRecommend,
|
||||
isDisagreeFriend: user.isDisagreeFriend,
|
||||
points: user.points,
|
||||
planPoints: user.planPoints,
|
||||
cardIds: user.cardIds,
|
||||
userCards: user.userCards,
|
||||
tags: user.tags,
|
||||
useBeta: user.useBeta,
|
||||
useNuo: user.useNuo,
|
||||
useServer: user.useServer,
|
||||
useB50Type: user.useB50Type,
|
||||
userHot: user.userHot,
|
||||
chatInGroupNumbers: user.chatInGroupNumbers,
|
||||
sc: user.sc,
|
||||
id2pcNuo: user.id2pcNuo,
|
||||
mai2links: user.mai2links,
|
||||
key2KeychipEn: user.key2KeychipEn,
|
||||
key2key2KeychipEn: user.key2key2KeychipEn,
|
||||
mai2link: user.mai2link,
|
||||
userRegion: user.userRegion,
|
||||
rinUsernameOrEmail: user.rinUsernameOrEmail,
|
||||
rinPassword: user.rinPassword,
|
||||
rinChusanUser: user.rinChusanUser,
|
||||
segaCards: newList, // 这里更新
|
||||
placeList: user.placeList,
|
||||
lastKeyChip: user.lastKeyChip,
|
||||
token: user.token,
|
||||
timesRegionData: user.timesRegionData,
|
||||
yearTotal: user.yearTotal,
|
||||
yearTotalComment: user.yearTotalComment,
|
||||
userCollCardMap: user.userCollCardMap,
|
||||
collName2musicIds: user.collName2musicIds,
|
||||
ai: user.ai,
|
||||
pkScore: user.pkScore,
|
||||
pkScoreStr: user.pkScoreStr,
|
||||
pkScoreReality: user.pkScoreReality,
|
||||
pkUserId: user.pkUserId,
|
||||
limitPkTimestamp: user.limitPkTimestamp,
|
||||
hasAcceptPk: user.hasAcceptPk,
|
||||
pkPlayNum: user.pkPlayNum,
|
||||
pkWin: user.pkWin,
|
||||
userData: user.userData,
|
||||
banState: user.banState,
|
||||
);
|
||||
|
||||
provider.updateUser(updatedUser);
|
||||
await provider.saveUserInfo();
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("✅ 已移除:${card.segaId}")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildScoreCheckerCard(UserModel user) {
|
||||
return _webCard(
|
||||
child: Column(
|
||||
@@ -1148,6 +1265,12 @@ class _UserPageState extends State<UserPage> {
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(card.segaId ?? "")),
|
||||
const SizedBox(width: 6),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
onPressed: () => _removeSegaCard(card, user),
|
||||
child: const Text("移除", style: TextStyle(fontSize: 12)),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
TextButton(
|
||||
onPressed: () => _verifyBoundSega(card),
|
||||
child: const Text("验证", style: TextStyle(fontSize: 12)),
|
||||
|
||||
Reference in New Issue
Block a user