소스 검색

初始化ConfigService 的初始化 Future 的问题

liukai 4 달 전
부모
커밋
cd17a75af5

+ 2 - 2
app/lib/main.dart

@@ -28,11 +28,11 @@ import 'package:widgets/dialog/custom_loading_widget.dart';
 import 'package:widgets/widget_export.dart';
 import 'router/page_router.dart';
 
-void main() {
+void main() async{
   //运行App
   // FlutterBugly.postCatchedException(() async {
     //交给初始化构造器去统一初始化
-    AppInitializer.initializeRunalone();
+    await AppInitializer.initializeRunalone();
 
     //全局自定义单例服务的注入
     GlobalServicesInjection.init(additionalDependencies: () {

+ 1 - 1
app/lib/modules/splash/splash_controller.dart

@@ -45,7 +45,7 @@ void _gotoNextPage() async {
 
   if (UserService.to.isLogin) {
     //去Attendance页面签到
-    Log.d("去Attendance页面签到");
+    Log.d("去首页页面");
     ComponentRouterServices.authService.startPopAllMainPage();
   } else {
     //去登录页面

+ 2 - 3
packages/cs_initializer/lib/app_initializer.dart

@@ -1,4 +1,3 @@
-
 import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
@@ -83,7 +82,7 @@ class AppInitializer {
    * 3.入口初始化方法 - Platform 插件中的Engine其他功能初始化
    * 独立运行模块中的 main.dart 配置,用于测试
    */
-  static void initializeRunalone() async {
+  static Future initializeRunalone() async {
     //FT框架初始化
     WidgetsFlutterBinding.ensureInitialized();
 
@@ -98,7 +97,7 @@ class AppInitializer {
     DirectoryUtil.getInstance(); //SD卡管控
 
     //注入全局单例Service(内部包含 AppInfo,DeviceInfo 等初始化,并注入了 ConfigService 配置服务类)
-    ConfigServicesInjection.init();
+    await ConfigServicesInjection.init();
 
     //指定页面的展示方向为哪一种,常用的三种屏幕方向
     SystemChrome.setPreferredOrientations([

+ 3 - 1
packages/cs_initializer/lib/global_services_injection.dart

@@ -26,7 +26,7 @@ class GlobalServicesInjection {
     Get.put(
         HttpProvider(
           ApiConstants.baseUrl,
-          interceptors: [StatusCodeDioInterceptors(), AuthDioInterceptors()],  //需要加上与App关联的一些拦截处理
+          interceptors: [StatusCodeDioInterceptors(), AuthDioInterceptors()], //需要加上与App关联的一些拦截处理
         ),
         permanent: true);
 
@@ -44,5 +44,7 @@ class GlobalServicesInjection {
     if (additionalDependencies != null) {
       additionalDependencies();
     }
+
+    Log.d('----ConfigServicesInjection------end-----');
   }
 }