fix(mobile-app): fix avatar upload response parsing
Parse avatarUrl from nested data object in API response 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2613a601b4
commit
0622dd14d9
|
|
@ -883,8 +883,18 @@ class AccountService {
|
|||
}
|
||||
|
||||
final responseData = response.data as Map<String, dynamic>;
|
||||
final newAvatarUrl = responseData['avatarUrl'] as String;
|
||||
debugPrint('$_tag uploadAvatar() - responseData: $responseData');
|
||||
// API 返回格式: { success: true, data: { message, avatarUrl } }
|
||||
final data = responseData['data'] as Map<String, dynamic>?;
|
||||
debugPrint('$_tag uploadAvatar() - data: $data');
|
||||
if (data == null) {
|
||||
throw const ApiException('上传头像失败: 响应数据格式错误');
|
||||
}
|
||||
final newAvatarUrl = data['avatarUrl'] as String?;
|
||||
debugPrint('$_tag uploadAvatar() - 新头像URL: $newAvatarUrl');
|
||||
if (newAvatarUrl == null || newAvatarUrl.isEmpty) {
|
||||
throw const ApiException('上传头像失败: 未返回头像URL');
|
||||
}
|
||||
|
||||
// 更新本地存储(使用 avatarUrl 而不是 avatarSvg)
|
||||
await _secureStorage.write(key: StorageKeys.avatarUrl, value: newAvatarUrl);
|
||||
|
|
|
|||
Loading…
Reference in New Issue