基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
1.5 KiB

  1. import 'package:zhiying_comm/util/net_util.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. class BaseSettingModel {
  4. String fileProvider;
  5. String fileBucketHost;
  6. String fileBucketHostProtocol;
  7. Map<String, dynamic> tab;
  8. static BaseSettingModel _setting;
  9. static BaseSettingModel get setting {
  10. if (_setting == null) {
  11. Logger.error('暂未初始化');
  12. }
  13. return _setting;
  14. }
  15. BaseSettingModel(
  16. {this.fileProvider, this.fileBucketHost, this.fileBucketHostProtocol});
  17. BaseSettingModel.fromJson(Map<String, dynamic> json) {
  18. fileProvider = json['file_provider'];
  19. fileBucketHost = json['file_bucket_host'];
  20. fileBucketHostProtocol = json['file_bucket_host_protocol'];
  21. tab = Map<String, dynamic>.from(json['bottom_nav']);
  22. }
  23. Map<String, dynamic> toJson() {
  24. final Map<String, dynamic> data = new Map<String, dynamic>();
  25. data['file_provider'] = this.fileProvider;
  26. data['file_bucket_host'] = this.fileBucketHost;
  27. data['file_bucket_host_protocol'] = this.fileBucketHostProtocol;
  28. data['bottom_nav'] = this.tab;
  29. return data;
  30. }
  31. static Future<BaseSettingModel> init() async {
  32. Map result =
  33. await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET);
  34. try {
  35. var data = result['data'];
  36. _setting = BaseSettingModel.fromJson(Map<String, dynamic>.from(data));
  37. Logger.debug('基础设置初始化');
  38. return _setting;
  39. } catch (err) {
  40. Logger.error(err);
  41. }
  42. return null;
  43. }
  44. }