diff --git a/lib/views/pb_setting_page/pb_setting_page.dart b/lib/views/pb_setting_page/pb_setting_page.dart index 60a80d8..6c91aaf 100644 --- a/lib/views/pb_setting_page/pb_setting_page.dart +++ b/lib/views/pb_setting_page/pb_setting_page.dart @@ -99,16 +99,7 @@ class _PBSettingPageState extends State if (status == PermissionStatus.granted) { var result = await BarcodeScanner.scan(); if (result.type == ResultType.Barcode) { - showDialog( - context: context, - builder: (context) { - return NetLoadingDialog( - loading: true, - outsideDismiss: false, - loadingText: '转换中...', - requestCallBack: _presenter.doTransferJson(result.rawContent), - ); - }); + _presenter.doTransferJson(result.rawContent); } } else { PermissionUtils.showPermissionDialog(context); diff --git a/lib/views/pb_setting_page/pb_setting_presenter.dart b/lib/views/pb_setting_page/pb_setting_presenter.dart index 8e1dc64..53339a8 100644 --- a/lib/views/pb_setting_page/pb_setting_presenter.dart +++ b/lib/views/pb_setting_page/pb_setting_presenter.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_picgo/model/gitee_config.dart'; import 'package:flutter_picgo/model/github_config.dart'; import 'package:flutter_picgo/model/pb_setting.dart'; +import 'package:flutter_picgo/model/qiniu_config.dart'; import 'package:flutter_picgo/model/smms_config.dart'; import 'package:flutter_picgo/resources/pb_type_keys.dart'; import 'package:flutter_picgo/utils/image_upload.dart'; @@ -41,24 +42,11 @@ class PBSettingPagePresenter { /// transfer picgo json config to flutter-picgo doTransferJson(String jsonStr) async { try { - var map = json.decode(jsonStr); - // decode github - if (map[PBTypeKeys.github] != null) { - var githubConfig = - json.encode(GithubConfig.fromJson(map[PBTypeKeys.github])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.github, githubConfig); - } - // decode smms - if (map[PBTypeKeys.smms] != null) { - var smmsConfig = json.encode(SMMSConfig.fromJson(map[PBTypeKeys.smms])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.smms, smmsConfig); - } - - if (map[PBTypeKeys.gitee] != null) { - var giteeConfig = - json.encode(GiteeConfig.fromJson(map[PBTypeKeys.gitee])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.gitee, giteeConfig); - } + Map map = json.decode(jsonStr); + map.forEach((key, value) async { + var config = json.encode(value); + await ImageUploadUtils.savePBConfig(key, config); + }); // success _view.transferSuccess(); } catch (e) {