Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
netrain_flutter_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
netrain_flutter_app
Commits
c53ccd34
Commit
c53ccd34
authored
Jul 07, 2021
by
“Icebear”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化code,msg,data
parent
6f0c4e5a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
HttpManager.dart
netrain_flutter_app/lib/zhangfeng/Network/HttpManager.dart
+1
-1
ResponseInterceptor.dart
...lutter_app/lib/zhangfeng/Network/ResponseInterceptor.dart
+6
-8
ResultData.dart
netrain_flutter_app/lib/zhangfeng/Network/ResultData.dart
+2
-2
No files found.
netrain_flutter_app/lib/zhangfeng/Network/HttpManager.dart
View file @
c53ccd34
...
@@ -132,5 +132,5 @@ ResultData resultError(DioError e) {
...
@@ -132,5 +132,5 @@ ResultData resultError(DioError e) {
errorResponse
.
statusCode
=
Code
.
NETWORK_TIMEOUT
;
errorResponse
.
statusCode
=
Code
.
NETWORK_TIMEOUT
;
}
}
return
new
ResultData
(
return
new
ResultData
(
errorResponse
.
statusMessage
,
false
,
errorResponse
.
statusCod
e
);
null
,
false
,-
1
,
errorResponse
.
statusMessag
e
);
}
}
netrain_flutter_app/lib/zhangfeng/Network/ResponseInterceptor.dart
View file @
c53ccd34
...
@@ -9,7 +9,7 @@ class ResponseInterceptors extends InterceptorsWrapper {
...
@@ -9,7 +9,7 @@ class ResponseInterceptors extends InterceptorsWrapper {
try
{
try
{
if
(
option
.
contentType
!=
null
&&
option
.
contentType
.
contains
(
"text"
))
{
if
(
option
.
contentType
!=
null
&&
option
.
contentType
.
contains
(
"text"
))
{
response
.
data
=
ResultData
(
response
.
data
,
true
,
200
);
response
.
data
=
ResultData
(
response
.
data
,
true
,
0
,
''
);
handler
.
next
(
response
);
handler
.
next
(
response
);
}
}
...
@@ -18,25 +18,23 @@ class ResponseInterceptors extends InterceptorsWrapper {
...
@@ -18,25 +18,23 @@ class ResponseInterceptors extends InterceptorsWrapper {
///内层需要根据公司实际返回结构解析,一般会有code,data,msg字段
///内层需要根据公司实际返回结构解析,一般会有code,data,msg字段
int
code
=
response
.
data
[
"code"
];
int
code
=
response
.
data
[
"code"
];
String
msg
=
response
.
data
[
"msg"
];
if
(
code
==
0
)
{
if
(
code
==
0
)
{
response
.
data
=
ResultData
(
response
.
data
,
true
,
200
,
response
.
data
=
ResultData
(
response
.
data
,
true
,
code
,
msg
);
headers:
response
.
headers
);
handler
.
next
(
response
);
handler
.
next
(
response
);
}
else
{
}
else
{
response
.
data
=
ResultData
(
response
.
data
,
false
,
200
,
response
.
data
=
ResultData
(
response
.
data
,
false
,
code
,
msg
);
headers:
response
.
headers
);
handler
.
next
(
response
);
handler
.
next
(
response
);
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
print
(
"ResponseError===="
+
e
.
toString
()
+
"****"
+
option
.
path
);
print
(
"ResponseError===="
+
e
.
toString
()
+
"****"
+
option
.
path
);
response
.
data
=
ResultData
(
response
.
data
,
false
,
response
.
statusCode
,
response
.
data
=
ResultData
(
response
.
data
,
false
,
-
1
,
'网络有误'
);
headers:
response
.
headers
);
handler
.
next
(
response
);
handler
.
next
(
response
);
}
}
response
.
data
=
ResultData
(
response
.
data
,
false
,
response
.
statusCode
,
headers:
response
.
headers
);
response
.
data
=
ResultData
(
response
.
data
,
false
,
-
1
,
'网络有误'
);
handler
.
next
(
response
);
handler
.
next
(
response
);
}
}
}
}
netrain_flutter_app/lib/zhangfeng/Network/ResultData.dart
View file @
c53ccd34
...
@@ -2,7 +2,7 @@ class ResultData {
...
@@ -2,7 +2,7 @@ class ResultData {
var
data
;
var
data
;
bool
isSuccess
;
bool
isSuccess
;
int
code
;
int
code
;
var
headers
;
var
msg
;
ResultData
(
this
.
data
,
this
.
isSuccess
,
this
.
code
,
{
this
.
headers
}
);
ResultData
(
this
.
data
,
this
.
isSuccess
,
this
.
code
,
this
.
msg
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment