1
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'package:app/providers/user_store.dart';
|
||||
import 'package:app/router/route_paths.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class SplashPage extends StatefulWidget {
|
||||
const SplashPage({super.key});
|
||||
@@ -19,7 +21,24 @@ class _SplashPageState extends State<SplashPage> {
|
||||
///权限效验初始化
|
||||
void initPermission() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
context.go(RoutePaths.login);
|
||||
String token = await UserStore.getToken();
|
||||
if (mounted) {
|
||||
// 未登录
|
||||
if (token.isEmpty) {
|
||||
context.go(RoutePaths.login);
|
||||
} else {
|
||||
UserStore userStore = context.read<UserStore>();
|
||||
userStore.setUserInfo();
|
||||
//去学生主页
|
||||
if (userStore.userInfo?.accountType == 1) {
|
||||
context.go(RoutePaths.sHome);
|
||||
} else {
|
||||
context.go(RoutePaths.tHome);
|
||||
}
|
||||
print("执行用户数据同步了");
|
||||
userStore.asyncUserInfo();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user