Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
519430378qqcom committed Apr 28, 2019
2 parents 127b029 + 7365e64 commit ebb3dcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dio网络请求日志插件
dio_log:
git:
url: ssh://git@gitlabssh.office.tengyue360.com:8042/cuidong/dio_log.git
ref: v1.0.1
ref: v1.0.0
### 设置dio拦截器
dio.interceptors.add(HttpLogInterceptor());
### 打开log日志列表
Expand Down
14 changes: 5 additions & 9 deletions lib/http_log_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ class _HttpLogWidgetState extends State<HttpLogWidget>
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Hero(
tag: widget
.httpLog.options.queryParameters[HttpLogInterceptor.reqTimeKey],
child: Text(
widget.httpLog.options.path,
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF4a4a4a),
),
title: Text(
widget.httpLog.options.path,
style: TextStyle(
fontSize: 16.0,
color: Color(0xFF4a4a4a),
),
),
backgroundColor: Colors.white,
Expand Down
9 changes: 5 additions & 4 deletions lib/request_log_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ class _RequestLogWidgetState extends State<RequestLogWidget> {
options.queryParameters[HttpLogInterceptor.reqTimeKey]));

///格式化返回时间
if (options.queryParameters[HttpLogInterceptor.resTimeKey] == null) {
var resTime = options.queryParameters[HttpLogInterceptor.resTimeKey];
if (resTime == null) {
reqFail = true;
resTime = 0;
}
var responseTime = reqFail
? '请求失败'
: _getTimeStr(DateTime.fromMillisecondsSinceEpoch(
options.queryParameters[HttpLogInterceptor.resTimeKey] ?? 0));
: _getTimeStr(DateTime.fromMillisecondsSinceEpoch(resTime));

///计算请求耗时
var duration =
'${options.queryParameters[HttpLogInterceptor.resTimeKey] ?? 0 - options.queryParameters[HttpLogInterceptor.reqTimeKey]}ms';
'${resTime - options.queryParameters[HttpLogInterceptor.reqTimeKey]}ms';
if (reqFail) {
duration = '遥遥无期';
}
Expand Down

0 comments on commit ebb3dcb

Please sign in to comment.