splash_controller.dart 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'package:get/get.dart';
  2. import 'package:app/jpush/jpush_receive.dart';
  3. import 'package:initializer/app_initializer.dart';
  4. import 'package:plugin_basic/constants/app_constant.dart';
  5. import 'package:plugin_basic/service/user_service.dart';
  6. import 'package:plugin_platform/engine/sp/sp_util.dart';
  7. import 'package:router/componentRouter/component_router_service.dart';
  8. import 'package:shared/utils/device_utils.dart';
  9. import 'package:shared/utils/log_utils.dart';
  10. import 'package:shared/utils/util.dart';
  11. class SplashController extends GetxController {
  12. @override
  13. void onReady() {
  14. super.onReady();
  15. UserService.to;
  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("去首页页面");
  42. ComponentRouterServices.authService.startPopAllMainPage();
  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. }