splash_controller.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/app_config_service.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("去首页页面");
  43. if (ConfigService.to.selectCountry.value == 1) {
  44. //去新加坡首页
  45. ComponentRouterServices.sgService.startSGMainPage();
  46. } else if (ConfigService.to.selectCountry.value == 2) {
  47. //去英国首页
  48. ComponentRouterServices.ukService.startUKMainPage();
  49. } else {
  50. //去越南首页
  51. ComponentRouterServices.vnService.startVNMainPage();
  52. }
  53. } else {
  54. //去登录页面
  55. Log.d("去登录页面");
  56. ComponentRouterServices.authService.startPopAllLoginPage();
  57. }
  58. // if (!Utils.isEmpty(routerName)) {
  59. // // 只跳转一次
  60. // Get.offAllNamed(routerName);
  61. // AppChannel.clearNativeRouterName();
  62. // } else {
  63. // // 如果没有经历过GUIDE页面,进入GUIDE,否则进入首页
  64. // MainPage.startWithPopAll();
  65. // }
  66. //跳转页面之后清除 Android 的 SplashScreen 库
  67. // if (Device.isAndroid) {
  68. // AppChannel.skipAndroidSplashScreen();
  69. // }
  70. }