splash_controller.dart 2.0 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. _gotoNextPage();
  17. }
  18. }
  19. void _gotoNextPage() async {
  20. await AppInitializer.delayInitialize(futureTasks: [
  21. () async {
  22. await FlutterBugly.init(
  23. androidAppId: "12345678",
  24. iOSAppId: "12345678",
  25. );
  26. },
  27. ], normalTasks: [
  28. () {
  29. if (DeviceUtils.isIOS || DeviceUtils.isAndroid) {
  30. jpush.init();
  31. }
  32. },
  33. ]);
  34. // 先查询原生平台有没有保存需要跳转的子路由
  35. // String routerName = await AppChannel.getNativeRouterName();
  36. // Log.d('SplashController - 查询原生平台有没有保存需要跳转的子路由:$routerName');
  37. String? token = SPUtil.getString(AppConstant.storageToken);
  38. UserService.to.setToken(token);
  39. if (UserService.to.isLogin) {
  40. //去Attendance页面签到
  41. Log.d("去Attendance页面签到");
  42. ComponentRouterServices.jobService.startWithPopSignInSignOutPage();
  43. } else {
  44. //去登录页面
  45. Log.d("去登录页面");
  46. ComponentRouterServices.authService.startPopAllLoginPage();
  47. }
  48. // if (!Utils.isEmpty(routerName)) {
  49. // // 只跳转一次
  50. // Get.offAllNamed(routerName);
  51. // AppChannel.clearNativeRouterName();
  52. // } else {
  53. // // 如果没有经历过GUIDE页面,进入GUIDE,否则进入首页
  54. // MainPage.startWithPopAll();
  55. // }
  56. //跳转页面之后清除 Android 的 SplashScreen 库
  57. // if (Device.isAndroid) {
  58. // AppChannel.skipAndroidSplashScreen();
  59. // }
  60. }