diff --git a/android/app/build.gradle b/android/app/build.gradle index f652ce3..d89382c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -20,13 +20,11 @@ def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } - apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/lib/main.dart b/lib/main.dart index f48df6c..6115b5d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -72,11 +72,7 @@ class _MyAppState extends State { void initState() { super.initState(); // final service = FlutterBackgroundService(); - // Future.delayed(const Duration(milliseconds: 0), () async { - // //Hive.initFlutter; - // }); _Getpermission(); - HiveStore.init(); registerWxApi( appId: "wxd930ea5d5a228f5f",universalLink:"https://your.univerallink.com/link/ " ); diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index aa06b38..71bac28 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -1,7 +1,15 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:project_telephony/ui/tab_navigator.dart'; import 'dart:async'; import 'package:project_telephony/utils/headers.dart'; +import 'package:provider/provider.dart'; + +import '../constants/environment/environment.dart'; +import '../providers/user_provider.dart'; +import '../utils/hive_store.dart'; +import 'login/login_page.dart'; class Loading extends StatefulWidget { Loading({Key? key}) : super(key: key); @@ -12,11 +20,27 @@ class Loading extends StatefulWidget { class _LoadingState extends State { + Future initialAll() async { + await HiveStore.init(); + } + @override void initState() { - // TODO: implement initState super.initState(); - + final userProvider = Provider.of(context, listen: false); + var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); + if (kDebugMode) { + print('env :$env'); + } + DevEV.instance.setEnvironment( context, environment: env == 'dev',); + Future.delayed(const Duration(milliseconds: 1000), () async { + await initialAll(); + if (!await userProvider.init()) { + await Get.offAll(() => const LoginPage()); + } else { + await Get.offAll(() => const TabNavigator()); + } + }); Future.delayed(const Duration(seconds: 3),(){ //3秒后跳转到其他路由 Navigator.of(context).pushReplacementNamed("/TabNavigator"); diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 91aab9e..0bcf46b 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -5,6 +5,7 @@ import 'package:project_telephony/ui/user/user_page.dart'; import 'package:project_telephony/utils/headers.dart'; +import '../utils/hive_store.dart'; import 'home/home_page.dart'; class TabNavigator extends StatefulWidget { @@ -29,8 +30,8 @@ class _TabNavigatorState extends State super.initState(); //页面加载调用 Future.delayed(const Duration(milliseconds: 0), () async { - // Hive.initFLutter; - // await HiveStore.init() + //Hive.initFlutter; + await HiveStore.init(); }); _pages = [const HomePage(), const UserPage()]; _tabController = TabController(