Browse Source

1、单点登录,执行退出登录(临时解决)

tags/0.0.2+5^0
PH2 4 years ago
parent
commit
13e63e5a2e
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      lib/util/net_util.dart

+ 18
- 0
lib/util/net_util.dart View File

@@ -6,6 +6,7 @@ import 'dart:ui';
import 'package:device_info/device_info.dart';
import 'package:dio/adapter.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:imei_plugin/imei_plugin.dart';
import 'package:package_info/package_info.dart';
@@ -16,10 +17,14 @@ import 'global_config.dart';
import 'shared_prefe_util.dart';
import 'time_util.dart';

import 'package:provider/provider.dart';

typedef OnSuccess = dynamic Function(dynamic data);
typedef OnError = dynamic Function(String e);
typedef OnCache = dynamic Function(dynamic data);

final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();

enum NetMethod {
GET,
POST,
@@ -132,6 +137,19 @@ class NetUtil {
);
}

// 退出登陆
if(result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003'){
try {
Future.delayed(Duration(seconds: 0)).then((onValue) {
BuildContext context = navigatorKey.currentState.overlay.context;
Provider.of<UserInfoNotifier>(context, listen: false).unLogin();
});

}catch(e,s ){
Logger.error(e,s );
}
}

return result;
}
} catch (e) {


Loading…
Cancel
Save