File tree Expand file tree Collapse file tree 6 files changed +37
-5
lines changed Expand file tree Collapse file tree 6 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
8383 _context = context;
8484 return NavigatorUtils .pageContainer (new LoginPage ());
8585 },
86+
8687 ///使用 ModalRoute.of(context).settings.arguments; 获取参数
8788 PhotoViewPage .sName: (context) {
8889 return PhotoViewPage ();
@@ -138,12 +139,20 @@ mixin HttpErrorListener on State<FlutterReduxApp> {
138139 case 404 :
139140 Fluttertoast .showToast (
140141 msg: GSYLocalizations .i18n (_context).network_error_404);
142+ case 422 :
143+ Fluttertoast .showToast (
144+ msg: GSYLocalizations .i18n (_context).network_error_422);
141145 break ;
142146 case Code .NETWORK_TIMEOUT :
143147 //超时
144148 Fluttertoast .showToast (
145149 msg: GSYLocalizations .i18n (_context).network_error_timeout);
146150 break ;
151+ case Code .GITHUB_API_REFUSED :
152+ //超时
153+ Fluttertoast .showToast (
154+ msg: GSYLocalizations .i18n (_context).network_error_timeout);
155+ break ;
147156 default :
148157 Fluttertoast .showToast (
149158 msg: GSYLocalizations .i18n (_context).network_error_unknown +
Original file line number Diff line number Diff line change @@ -95,12 +95,16 @@ abstract class GSYStringBase {
9595
9696 String get network_error_404;
9797
98+ String get network_error_422;
99+
98100 String get network_error_timeout;
99101
100102 String get network_error_unknown;
101103
102104 String get network_error;
103105
106+ String get github_refused;
107+
104108 String get load_more_not;
105109
106110 String get load_more_text;
Original file line number Diff line number Diff line change 11import 'package:gsy_github_app_flutter/common/localization/gsy_string_base.dart' ;
2+ import 'package:gsy_github_app_flutter/common/localization/gsy_string_base.dart' ;
23
34/**
45 * Created by guoshuyu
@@ -110,12 +111,15 @@ class GSYStringEn extends GSYStringBase {
110111 @override
111112 String network_error_404 = "Http 404" ;
112113 @override
114+ String network_error_422 = "Request Body Error,Please Check Github ClientId" ;
115+ @override
113116 String network_error_timeout = "Http timeout" ;
114117 @override
115118 String network_error_unknown = "Http unknown error" ;
116119 @override
117120 String network_error = "network error" ;
118-
121+ @override
122+ String github_refused = "Github Api Error[OS Error: Connection refused]. Please switch networks or try again later " ;
119123 @override
120124 String load_more_not = "nothing" ;
121125 @override
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ class GSYStringZh extends GSYStringBase {
9898 String home_theme_6 = "主题6" ;
9999
100100 @override
101- String login_username_hint_text = "请输入github用户名 " ;
101+ String login_username_hint_text = "github用户名,清不要用邮箱 " ;
102102 @override
103103 String login_password_hint_text = "请输入密码" ;
104104 @override
@@ -111,12 +111,15 @@ class GSYStringZh extends GSYStringBase {
111111 @override
112112 String network_error_404 = "404错误" ;
113113 @override
114+ String network_error_422 = "请求实体异常,请确保 Github ClientId 等信息正确。" ;
115+ @override
114116 String network_error_timeout = "请求超时" ;
115117 @override
116118 String network_error_unknown = "其他异常" ;
117119 @override
118120 String network_error = "网络错误" ;
119-
121+ @override
122+ String github_refused = "Github Api 出现异常[Connection refused],建议换个网络环境或者稍后再试" ;
120123 @override
121124 String load_more_not = "没有更多数据" ;
122125 @override
Original file line number Diff line number Diff line change @@ -12,12 +12,18 @@ class Code {
1212 ///网络返回数据格式化一次
1313 static const NETWORK_JSON_EXCEPTION = - 3 ;
1414
15+ ///Github APi Connection refused
16+ static const GITHUB_API_REFUSED = - 4 ;
17+
1518 static const SUCCESS = 200 ;
1619
1720 static errorHandleFunction (code, message, noTip) {
1821 if (noTip) {
1922 return message;
2023 }
24+ if (message != null && message is String && message.contains ("Connection refused" )) {
25+ code = GITHUB_API_REFUSED ;
26+ }
2127 eventBus.fire (new HttpErrorEvent (code, message));
2228 return message;
2329 }
Original file line number Diff line number Diff line change @@ -30,7 +30,12 @@ class LogsInterceptors extends InterceptorsWrapper {
3030 }
3131 try {
3232 addLogic (sRequestHttpUrl, options.path ?? "" );
33- var data = options.data ?? Map <String , dynamic >();
33+ var data;
34+ if (options.data is Map ) {
35+ data = options.data;
36+ } else {
37+ data = Map <String , dynamic >();
38+ }
3439 var map = {
3540 "header:" : {...options.headers},
3641 };
@@ -39,6 +44,7 @@ class LogsInterceptors extends InterceptorsWrapper {
3944 }
4045 addLogic (sHttpRequest, map);
4146 } catch (e) {
47+ print ("########2" );
4248 print (e);
4349 }
4450 return options;
@@ -85,7 +91,7 @@ class LogsInterceptors extends InterceptorsWrapper {
8591 onError (DioError err) async {
8692 if (Config .DEBUG ) {
8793 print ('请求异常: ' + err.toString ());
88- print ('请求异常信息: ' + err.response? .toString () ?? "" );
94+ print ('请求异常信息: ' + ( err.response? .toString () ?? "" ) );
8995 }
9096 try {
9197 addLogic (sHttpErrorUrl, err.request.path ?? "null" );
You can’t perform that action at this time.
0 commit comments