12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import 'dart:convert';
- import 'package:flyinsonolite/jsonrpc/fisLib/services/log.m.dart';
- import 'package:flyinsonolite/infrastructure/logger.dart';
- import 'package:flyinsonolite/managers/configurationmanager.dart';
- import 'package:flyinsonolite/consultation/reports/models/reporteditsetting.dart';
- import 'package:flyinsonolite/services/sharedstorageservice.dart';
- import 'package:get/get.dart';
- /// 本地报告编辑器服务
- class LocalReportEditorService extends GetxService {
- String _cache = "";
- /// 获取设置的缓存
- void restoreLocalCache() {
- try {
- var map = json.decode(_cache);
- ReportEditorSetting.ins.setDataFromJson(map);
- } catch (e) {
- loggerAsyn(FISDeviceLogCategory.Error,
- 'LocalReportEditorService restoreLocalCache ex:$e');
- }
- }
- ///初始化
- void init() async {
- // 创建实例
- final list =
- SharedStorageService.ins.getString(StoreKeys.reportEditSetting);
- if (list == null) {
- _cache = "";
- } else {
- _cache = list;
- restoreLocalCache();
- }
- }
- ///保存配置
- Future<bool> saveAsync() async {
- var jsonStr = json.encode(ReportEditorSetting.ins.toJson());
- return await SharedStorageService.ins
- .setString(StoreKeys.reportEditSetting, jsonStr);
- }
- }
|