From ef909e648639757ac497c45fffbf902eed4907d0 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 20 Jan 2021 17:52:06 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E7=99=BB=E9=99=86=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/splash/splash_page.dart | 3 +++ lib/pages/tab_navigator.dart | 2 -- lib/provider/user_provider.dart | 7 ++++--- lib/utils/network/net_util.dart | 5 +++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index 1c64e3f8..55ea2f10 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -3,6 +3,7 @@ import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/logger/logger_view.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -35,6 +36,8 @@ class _SplashPageState extends State { @override Widget build(BuildContext context) { + ScreenUtil.init(context, + designSize: Size(750, 1334), allowFontScaling: true); return Scaffold( body: SizedBox( height: 80, diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index 3e520d21..22431361 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -60,8 +60,6 @@ class _TabNavigatorState extends State { @override Widget build(BuildContext context) { - ScreenUtil.init(context, - designSize: Size(750, 1334), allowFontScaling: true); //底部导航来 List _bottomNav = [ _buildBottomBar( diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 541e849c..919a0710 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -32,7 +32,7 @@ class UserProvider extends ChangeNotifier { _isLogin = false; _token = null; _userInfoModel = null; - _userDetailModel=null; + _userDetailModel = null; NetUtil().get(API.user.logout, showMessage: true); NetUtil().dio.options.headers.remove('App-Admin-Token'); HiveStore.appBox.delete('token'); @@ -45,8 +45,9 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } - Future updateUserDetail()async{ - _userDetailModel=await SignFunc.getUserDetail(); + Future updateUserDetail() async { + _userDetailModel = await SignFunc.getUserDetail(); + notifyListeners(); } String _token; diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 1260c61e..f067f05d 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/pages/sign/sign_in_page.dart'; import 'package:akuCommunity/utils/logger/logger_data.dart'; import 'package:akuCommunity/utils/network/base_list_model.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; @@ -5,6 +6,7 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart'; import 'package:akuCommunity/constants/api.dart'; +import 'package:get/get.dart' hide Response; import 'package:logger/logger.dart'; class NetUtil { @@ -142,6 +144,9 @@ class NetUtil { } _parseRequestError(BaseModel model, {bool showMessage = false}) { + if (!model.status&&model.message=='登录失效,请登录'){ + Get.offAll(SignInPage()); + } if (!model.status || showMessage) { BotToast.showText(text: model.message); }