Quellcode durchsuchen

1、新增web端持久化缓存机制

guanxinyi vor 1 Jahr
Ursprung
Commit
aaebf9376b
1 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen
  1. 11 2
      lib/pages/splash/view.dart

+ 11 - 2
lib/pages/splash/view.dart

@@ -1,7 +1,9 @@
 import 'dart:async';
 import 'dart:async';
 
 
+import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:get/get.dart';
+import 'package:vitalapp/store/store.dart';
 import 'controller.dart';
 import 'controller.dart';
 
 
 class SplashPage extends GetView<SplashController> {
 class SplashPage extends GetView<SplashController> {
@@ -38,8 +40,15 @@ class _ImageAnimationState extends State<ImageAnimation>
       _controller.loadData(),
       _controller.loadData(),
       animationCompleter.future,
       animationCompleter.future,
     ]).then((_) {
     ]).then((_) {
-      // 等待动画和数据加载,全部完成后跳转路由
-      _controller.onRouteTo();
+      /// 重启判断是否是web端并且无token
+      if (!kIsWeb || Store.user.token == null) {
+        _controller.onRouteTo();
+      }
+
+      /// web端 并且有token
+      if (kIsWeb && Store.user.token != null) {
+        Get.offAllNamed("/");
+      }
     });
     });
 
 
     // 创建动画控制器
     // 创建动画控制器