062f0df2
liangchengyou
feat:登录模块代码提交
|
1
|
import 'dart:async';
|
cc3b183a
liangchengyou
feat:ios启动图/logo
|
2
|
import 'dart:io';
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
3
|
import 'dart:math';
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
4
|
|
1892df31
Key
优化接口调用
|
5
|
import 'package:flutter/foundation.dart';
|
2a29701f
liangchengyou
feat:提交代码
|
6
|
import 'package:flutter/material.dart';
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
7
8
|
import 'package:flutter/services.dart';
import 'package:limiting_direction_csx/limiting_direction_csx.dart';
|
94342c3f
Key
feat: user util
|
9
|
import 'package:wow_english/common/core/user_util.dart';
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
10
|
import 'package:wow_english/common/extension/string_extension.dart';
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
11
12
|
import 'package:wow_english/common/request/config.dart';
import 'package:wow_english/common/request/dao/user_dao.dart';
|
94342c3f
Key
feat: user util
|
13
|
import 'package:wow_english/models/user_entity.dart';
|
2a29701f
liangchengyou
feat:提交代码
|
14
|
import 'package:wow_english/route/route.dart';
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
15
|
import 'package:wow_english/utils/log_util.dart';
|
94342c3f
Key
feat: user util
|
16
|
import 'package:wow_english/utils/sp_util.dart';
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
17
|
|
a117a5a3
liangchengyou
feat:更新代码
|
18
19
|
class SplashPage extends StatelessWidget {
const SplashPage({super.key});
|
2a29701f
liangchengyou
feat:提交代码
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
@override
Widget build(BuildContext context) {
return const TransitionView();
}
}
class TransitionView extends StatefulWidget {
const TransitionView({super.key});
@override
State<StatefulWidget> createState() {
return _TransitionViewState();
}
}
class _TransitionViewState extends State<TransitionView> {
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
37
|
Future startTime() async {
|
94342c3f
Key
feat: user util
|
38
39
|
// 判断是否登录
UserEntity? userEntity = UserUtil.getUser();
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
40
41
|
Log.d('当前模式:kDebugMode=$kDebugMode, kProfileMode=$kProfileMode, kReleaseMode=$kReleaseMode');
Log.d('当前API地址:${RequestConfig.baseUrl}');
|
1892df31
Key
优化接口调用
|
42
|
if (kDebugMode) {
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
43
44
45
46
47
48
49
50
51
52
53
54
55
|
Log.d('Splash读本地userEntity: $userEntity');
}
int apartInMilliseconds = 0;
// 调一下接口判断一下有效性再往下
if (userEntity != null) {
DateTime startTime = DateTime.now();
try {
userEntity = await UserDao.getUserInfo();
UserUtil.saveUser(userEntity);
} catch (e) {
e.logE();
}
apartInMilliseconds = DateTime.now().difference(startTime).inMilliseconds;
|
1892df31
Key
优化接口调用
|
56
|
}
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
57
58
59
|
Log.d('Splash getUserInfo 耗时:${apartInMilliseconds}ms');
int duration = max(2000 - apartInMilliseconds, 0);
Timer(Duration(milliseconds: duration), () {
|
210d15e0
Key
fixed: 账户注销接口
|
60
|
/*if (userEntity != null) {
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
61
|
pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
62
|
} else {
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
63
|
pushNamedAndRemoveUntil(AppRouteName.login, (route) => false);
|
210d15e0
Key
fixed: 账户注销接口
|
64
65
|
}*/
pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
66
67
68
69
70
71
|
});
}
@override
void initState() {
super.initState();
|
089ccd5c
Key
fixed: user util ...
|
72
73
74
75
76
|
init();
}
void init() async {
await SpUtil.preInit();
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
77
|
startTime();
|
cc3b183a
liangchengyou
feat:ios启动图/logo
|
78
79
80
81
82
83
84
85
86
|
changeDevice();
}
void changeDevice() async {
///设置设备默认方向
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isIOS) {
await LimitingDirectionCsx.setScreenDirection(DeviceDirectionMask.Landscape);
} else {
|
a4d8eaa2
Key
feat: 登录时账户有效性校验
|
87
|
await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
|
cc3b183a
liangchengyou
feat:ios启动图/logo
|
88
|
}
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
89
90
|
}
|
2a29701f
liangchengyou
feat:提交代码
|
91
92
93
|
@override
Widget build(BuildContext context) {
return Scaffold(
|
2a29701f
liangchengyou
feat:提交代码
|
94
|
body: Center(
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
95
96
97
98
|
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
99
|
'splash'.assetGif,
|
062f0df2
liangchengyou
feat:登录模块代码提交
|
100
|
),
|
94342c3f
Key
feat: user util
|
101
|
fit: BoxFit.fill)),
|
2a29701f
liangchengyou
feat:提交代码
|
102
103
104
105
|
),
),
);
}
|
056970d8
Key
feat: api
|
106
|
}
|