fix(mining): handle avatar URL vs SVG in mining page

This commit is contained in:
hailin 2025-12-09 18:56:58 -08:00
parent 91e54946ba
commit 526f90d33e
1 changed files with 41 additions and 7 deletions

View File

@ -463,14 +463,48 @@ class _MiningPageState extends ConsumerState<MiningPage> {
} }
/// SVG或默认头像 /// SVG或默认头像
/// _avatarSvg URL SVG
Widget _buildSvgOrDefaultAvatar() { Widget _buildSvgOrDefaultAvatar() {
if (_avatarSvg != null) { if (_avatarSvg != null && _avatarSvg!.isNotEmpty) {
return SvgPicture.string( // URL
_avatarSvg!, if (_avatarSvg!.startsWith('http://') || _avatarSvg!.startsWith('https://')) {
width: 80, return Image.network(
height: 80, _avatarSvg!,
fit: BoxFit.cover, width: 80,
); height: 80,
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const Center(
child: SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
),
);
},
errorBuilder: (context, error, stackTrace) {
return const Icon(
Icons.person,
size: 40,
color: Color(0xFF8B5A2B),
);
},
);
}
// SVG SVG
if (_avatarSvg!.contains('<svg') || _avatarSvg!.startsWith('<?xml')) {
return SvgPicture.string(
_avatarSvg!,
width: 80,
height: 80,
fit: BoxFit.cover,
);
}
} }
return const Icon( return const Icon(
Icons.person, Icons.person,