Skip to content

Commit

Permalink
fix: 捕获解码异常并修复在网页无法打开物品管理主页的问题 (#397)
Browse files Browse the repository at this point in the history
* fix: 调整判断顺序,网页上没有 Platform.isAndroid 这个方法

* fix: 捕获解码异常并处理
  • Loading branch information
he0119 authored Feb 6, 2024
1 parent 7e31187 commit 4825c7e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/
### Fixed

- 修复搜索位置无法显示的问题
- 捕获解码异常并修复在网页无法打开物品管理主页的问题

## [0.9.7] - 2024-02-05

Expand Down
4 changes: 2 additions & 2 deletions lib/storage/view/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class StorageHomeScreen extends StatelessWidget {
return MyHomePage(
activeTab: AppTab.storage,
actions: <Widget>[
// 仅支持安卓和网页
if (Platform.isAndroid || kIsWeb) const ScanQRIconButton(),
// 仅支持网页和安卓
if (kIsWeb || Platform.isAndroid) const ScanQRIconButton(),
const SearchIconButton(),
],
floatingActionButton: FloatingActionButton(
Expand Down
8 changes: 6 additions & 2 deletions lib/storage/view/widgets/scan_qr_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ class _ScanQRPageState extends State<ScanQRPage> {

bool validateStorageId(String id) {
Codec<String, String> 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;
}
}
}

0 comments on commit 4825c7e

Please sign in to comment.