|
- import 'package:zhiying_comm/util/net_util.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- class BaseSettingModel {
- String fileProvider;
- String fileBucketHost;
- String fileBucketHostProtocol;
- Map<String, dynamic> tab;
-
- static BaseSettingModel _setting;
-
- static BaseSettingModel get setting {
- if (_setting == null) {
- Logger.error('暂未初始化');
- }
- return _setting;
- }
-
- BaseSettingModel(
- {this.fileProvider, this.fileBucketHost, this.fileBucketHostProtocol});
-
- BaseSettingModel.fromJson(Map<String, dynamic> json) {
- fileProvider = json['file_provider'];
- fileBucketHost = json['file_bucket_host'];
- fileBucketHostProtocol = json['file_bucket_host_protocol'];
- tab = Map<String, dynamic>.from(json['bottom_nav']);
- }
-
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['file_provider'] = this.fileProvider;
- data['file_bucket_host'] = this.fileBucketHost;
- data['file_bucket_host_protocol'] = this.fileBucketHostProtocol;
- data['bottom_nav'] = this.tab;
- return data;
- }
-
- static Future<BaseSettingModel> init() async {
- Map result =
- await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET);
- try {
- var data = result['data'];
- _setting = BaseSettingModel.fromJson(Map<String, dynamic>.from(data));
- Logger.debug('基础设置初始化');
- return _setting;
- } catch (err) {
- Logger.error(err);
- }
- return null;
- }
- }
|