Commit 3e72c6ce4ccd7c296b1d8daa773548dd9521ee85
1 parent
98670c0d
feat:登录刷新配置信息
Showing
2 changed files
with
5 additions
and
2 deletions
lib/common/core/app_config_helper.dart
| @@ -22,8 +22,8 @@ class AppConfigHelper { | @@ -22,8 +22,8 @@ class AppConfigHelper { | ||
| 22 | static bool checkedUpdate = false; | 22 | static bool checkedUpdate = false; |
| 23 | 23 | ||
| 24 | // 获取用户信息 | 24 | // 获取用户信息 |
| 25 | - static Future<AppConfigEntity?> getAppConfig() async { | ||
| 26 | - if (configEntityEntity != null) { | 25 | + static Future<AppConfigEntity?> getAppConfig({ bool forceSync = false }) async { |
| 26 | + if (forceSync == false && configEntityEntity != null) { | ||
| 27 | return configEntityEntity; | 27 | return configEntityEntity; |
| 28 | } | 28 | } |
| 29 | configEntityEntity = await SystemDao.getAppConfig(); | 29 | configEntityEntity = await SystemDao.getAppConfig(); |
lib/common/request/dao/user_dao.dart
| @@ -2,6 +2,7 @@ import 'package:wow_english/common/core/user_util.dart'; | @@ -2,6 +2,7 @@ import 'package:wow_english/common/core/user_util.dart'; | ||
| 2 | import 'package:wow_english/models/user_entity.dart'; | 2 | import 'package:wow_english/models/user_entity.dart'; |
| 3 | import 'package:wow_english/utils/log_util.dart'; | 3 | import 'package:wow_english/utils/log_util.dart'; |
| 4 | 4 | ||
| 5 | +import '../../core/app_config_helper.dart'; | ||
| 5 | import '../request_client.dart'; | 6 | import '../request_client.dart'; |
| 6 | 7 | ||
| 7 | enum SmsType { login, change_passWord, stdDestroy } | 8 | enum SmsType { login, change_passWord, stdDestroy } |
| @@ -18,6 +19,8 @@ class UserDao { | @@ -18,6 +19,8 @@ class UserDao { | ||
| 18 | UserUtil.saveUser(data); | 19 | UserUtil.saveUser(data); |
| 19 | // 由于userInfo接口不会返回token,所以这里需要再次保存一下token | 20 | // 由于userInfo接口不会返回token,所以这里需要再次保存一下token |
| 20 | final token = data.token; | 21 | final token = data.token; |
| 22 | + //登录成功后刷新下配置信息 | ||
| 23 | + AppConfigHelper.getAppConfig(forceSync: true); | ||
| 21 | //登录成功后zip一下getUserInfo,因为进入首页需要的信息在userinfo里,保证进入首页数据是最新的 | 24 | //登录成功后zip一下getUserInfo,因为进入首页需要的信息在userinfo里,保证进入首页数据是最新的 |
| 22 | data = await getUserInfo(); | 25 | data = await getUserInfo(); |
| 23 | data?.token = token; | 26 | data?.token = token; |