splash_controller.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:flutter_bugly/flutter_bugly.dart';
  2. import 'package:get/get.dart';
  3. import 'package:app/jpush/jpush_receive.dart';
  4. import 'package:initializer/app_initializer.dart';
  5. import 'package:plugin_basic/constants/app_constant.dart';
  6. import 'package:plugin_basic/service/user_service.dart';
  7. import 'package:plugin_platform/engine/sp/sp_util.dart';
  8. import 'package:router/componentRouter/component_router_service.dart';
  9. import 'package:shared/utils/device_utils.dart';
  10. import 'package:shared/utils/log_utils.dart';
  11. import 'package:shared/utils/util.dart';
  12. class SplashController extends GetxController {
  13. @override
  14. void onReady() {
  15. super.onReady();
  16. UserService.to;
  17. _gotoNextPage();
  18. }
  19. }
  20. void _gotoNextPage() async {
  21. await AppInitializer.delayInitialize(futureTasks: [
  22. () async {
  23. await FlutterBugly.init(
  24. androidAppId: "12345678",
  25. iOSAppId: "12345678",
  26. );
  27. },
  28. ], normalTasks: [
  29. () {
  30. if (DeviceUtils.isIOS || DeviceUtils.isAndroid) {
  31. jpush.init();
  32. }
  33. },
  34. ]);
  35. // 先查询原生平台有没有保存需要跳转的子路由
  36. // String routerName = await AppChannel.getNativeRouterName();
  37. // Log.d('SplashController - 查询原生平台有没有保存需要跳转的子路由:$routerName');
  38. String? token = SPUtil.getString(AppConstant.storageToken);
  39. UserService.to.setToken(token);
  40. if (UserService.to.isLogin) {
  41. //去Attendance页面签到
  42. Log.d("去Attendance页面签到");
  43. ComponentRouterServices.authService.startPopAllMainPage();
  44. } else {
  45. //去登录页面
  46. Log.d("去登录页面");
  47. ComponentRouterServices.authService.startPopAllLoginPage();
  48. }
  49. // if (!Utils.isEmpty(routerName)) {
  50. // // 只跳转一次
  51. // Get.offAllNamed(routerName);
  52. // AppChannel.clearNativeRouterName();
  53. // } else {
  54. // // 如果没有经历过GUIDE页面,进入GUIDE,否则进入首页
  55. // MainPage.startWithPopAll();
  56. // }
  57. //跳转页面之后清除 Android 的 SplashScreen 库
  58. // if (Device.isAndroid) {
  59. // AppChannel.skipAndroidSplashScreen();
  60. // }
  61. }