fix(mining-app): 修复转账二维码扫描无效问题

- 修改二维码生成格式为 durian://transfer/?phone=xxx (添加路径分隔符)
- 更新解析函数使用正则匹配,兼容新旧格式

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-29 07:39:42 -08:00
parent 7a8a3a8fd1
commit 6bcfa18b01
2 changed files with 15 additions and 3 deletions

View File

@ -156,7 +156,7 @@ class ReceiveSharesPage extends ConsumerWidget {
), ),
), ),
child: QrImageView( child: QrImageView(
data: 'durian://transfer?phone=$phone', data: 'durian://transfer/?phone=$phone',
version: QrVersions.auto, version: QrVersions.auto,
size: 200, size: 200,
backgroundColor: Colors.white, backgroundColor: Colors.white,

View File

@ -246,11 +246,23 @@ class _QrScannerSheetState extends State<QrScannerSheet> {
} }
/// ///
/// : durian://transfer?phone={phone} /// : durian://transfer/?phone={phone} durian://transfer?phone={phone}
/// null /// null
String? parseTransferQrCode(String qrCode) { String? parseTransferQrCode(String qrCode) {
try { try {
final uri = Uri.parse(qrCode); final trimmed = qrCode.trim();
// 使 /
// durian://transfer/?phone=xxx durian://transfer?phone=xxx
final regex = RegExp(r'^durian://transfer/?[?]phone=(\d{11})$');
final match = regex.firstMatch(trimmed);
if (match != null) {
return match.group(1);
}
// 使 Uri.parse
final uri = Uri.parse(trimmed);
// scheme // scheme
if (uri.scheme != 'durian') return null; if (uri.scheme != 'durian') return null;