From 4825c7e66eebf330827b611b92530ee239673bfd Mon Sep 17 00:00:00 2001 From: uy/sun Date: Tue, 6 Feb 2024 18:29:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8D=95=E8=8E=B7=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80=E7=89=A9=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=BB=E9=A1=B5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#397)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 调整判断顺序,网页上没有 Platform.isAndroid 这个方法 * fix: 捕获解码异常并处理 --- CHANGELOG.md | 1 + lib/storage/view/home_page.dart | 4 ++-- lib/storage/view/widgets/scan_qr_icon_button.dart | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca4cd91..527a523e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/ ### Fixed - 修复搜索位置无法显示的问题 +- 捕获解码异常并修复在网页无法打开物品管理主页的问题 ## [0.9.7] - 2024-02-05 diff --git a/lib/storage/view/home_page.dart b/lib/storage/view/home_page.dart index 64b13db3..8cefa376 100644 --- a/lib/storage/view/home_page.dart +++ b/lib/storage/view/home_page.dart @@ -50,8 +50,8 @@ class StorageHomeScreen extends StatelessWidget { return MyHomePage( activeTab: AppTab.storage, actions: [ - // 仅支持安卓和网页 - if (Platform.isAndroid || kIsWeb) const ScanQRIconButton(), + // 仅支持网页和安卓 + if (kIsWeb || Platform.isAndroid) const ScanQRIconButton(), const SearchIconButton(), ], floatingActionButton: FloatingActionButton( diff --git a/lib/storage/view/widgets/scan_qr_icon_button.dart b/lib/storage/view/widgets/scan_qr_icon_button.dart index 2031c57e..5308e00f 100644 --- a/lib/storage/view/widgets/scan_qr_icon_button.dart +++ b/lib/storage/view/widgets/scan_qr_icon_button.dart @@ -166,7 +166,11 @@ class _ScanQRPageState extends State { bool validateStorageId(String id) { Codec stringToBase64 = utf8.fuse(base64); - final decoded = stringToBase64.decode(id); - return decoded.startsWith('Storage:'); + try { + final decoded = stringToBase64.decode(id); + return decoded.startsWith('Storage:'); + } catch (e) { + return false; + } } }