@@ -10,6 +10,7 @@ import 'package:get/get.dart' as getx;
10
10
import 'package:imboy/component/controller.dart' ;
11
11
import 'package:imboy/component/extension/device_ext.dart' ;
12
12
import 'package:imboy/component/extension/imboy_cache_manager.dart' ;
13
+ import 'package:imboy/component/helper/datetime.dart' ;
13
14
import 'package:imboy/component/helper/func.dart' ;
14
15
import 'package:imboy/component/helper/jwt.dart' ;
15
16
import 'package:imboy/component/http/http_client.dart' ;
@@ -71,10 +72,15 @@ String deviceId = '';
71
72
72
73
Future <void > init () async {
73
74
WakelockPlus .enable ();
75
+
76
+ await StorageService .init ();
77
+ // 放在 UserRepoLocal 前面
78
+ getx.Get .lazyPut (() => StorageService ());
79
+
74
80
// 解决使用自签证书报错问题
75
81
io.HttpOverrides .global = GlobalHttpOverrides ();
76
82
// Get.put(DeviceExt()); 需要放到靠前
77
- getx.Get .put ( DeviceExt ());
83
+ getx.Get .lazyPut (() => DeviceExt ());
78
84
79
85
PackageInfo packageInfo = await PackageInfo .fromPlatform ();
80
86
appVsn = packageInfo.version;
@@ -86,9 +92,6 @@ Future<void> init() async {
86
92
await dotenv.load (fileName: ".env" ); //
87
93
// iPrint("> on UP_AUTH_KEY: ${dotenv.get('UP_AUTH_KEY')}");
88
94
89
- // 放在 UserRepoLocal 前面
90
- await getx.Get .putAsync <StorageService >(() => StorageService ().init ());
91
-
92
95
getx.Get .put (UserRepoLocal (), permanent: true );
93
96
getx.Get .lazyPut (() => ThemeController ());
94
97
@@ -114,7 +117,7 @@ Future<void> init() async {
114
117
getx.Get .put (MessageService ());
115
118
// getx.Get.lazyPut(() => DeviceExt());
116
119
117
- ntpOffset = await StorageService .to. ntpOffset ();
120
+ ntpOffset = await DateTimeHelper . getNtpOffset ();
118
121
AMapHelper .setApiKey ();
119
122
120
123
// 初始化单例 WebSocketService
@@ -128,7 +131,7 @@ Future<void> init() async {
128
131
LifecycleEventHandler (
129
132
resumeCallBack: () async {
130
133
// app 恢复
131
- String token = UserRepoLocal .to.accessToken;
134
+ String ? token = UserRepoLocal .to.accessToken;
132
135
if (tokenExpired (token)) {
133
136
iPrint ('LifecycleEventHandler tokenExpired true' );
134
137
await (UserProvider ()).refreshAccessTokenApi (
@@ -138,7 +141,7 @@ Future<void> init() async {
138
141
// 统计新申请好友数量
139
142
bnLogic.countNewFriendRemindCounter ();
140
143
iPrint ("> on LifecycleEventHandler resumeCallBack" );
141
- ntpOffset = await StorageService .to. ntpOffset ();
144
+ ntpOffset = await DateTimeHelper . getNtpOffset ();
142
145
// 检查WS链接状态
143
146
WebSocketService .to.openSocket ();
144
147
},
0 commit comments