From a6cab55dcc11682ec3fc31b319d4e3b9b30a8b0a Mon Sep 17 00:00:00 2001 From: wanghongenpin <178070584@qq.com> Date: Thu, 21 Sep 2023 17:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=A0=BC=E5=BC=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/network/handler.dart | 2 +- lib/storage/favorites.dart | 1 + lib/ui/component/utils.dart | 12 ++++++------ lib/ui/content/panel.dart | 1 + lib/ui/desktop/left/favorite.dart | 1 + lib/ui/desktop/left/history.dart | 3 ++- lib/ui/desktop/left/search_condition.dart | 6 +++--- lib/utils/har.dart | 7 ++++++- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/network/handler.dart b/lib/network/handler.dart index ff467ce..b80a0fd 100644 --- a/lib/network/handler.dart +++ b/lib/network/handler.dart @@ -222,7 +222,7 @@ class HttpChannelHandler extends ChannelHandler { /// 异常处理 _exceptionHandler(Channel channel, HttpRequest? request, error) { HostAndPort? hostAndPort = channel.getAttribute(AttributeKeys.host); - hostAndPort ??= HostAndPort.host(channel.remoteAddress.host, channel.remotePort); + hostAndPort ??= HostAndPort.host(scheme:HostAndPort.httpScheme, channel.remoteAddress.host, channel.remotePort); String message = error.toString(); HttpStatus status = HttpStatus(-1, message); if (error is HandshakeException) { diff --git a/lib/storage/favorites.dart b/lib/storage/favorites.dart index a384dba..94fa07e 100644 --- a/lib/storage/favorites.dart +++ b/lib/storage/favorites.dart @@ -38,6 +38,7 @@ class FavoriteStorage { return file; } + /// 添加收藏 static Future addFavorite(HttpRequest request) async { var favorites = await FavoriteStorage.favorites; if (favorites.contains(request)) { diff --git a/lib/ui/component/utils.dart b/lib/ui/component/utils.dart index d0dd1f3..f1a379f 100644 --- a/lib/ui/component/utils.dart +++ b/lib/ui/component/utils.dart @@ -88,12 +88,12 @@ Widget contextMenu(BuildContext context, EditableTextState editableTextState) { ) ]; if (Platform.isIOS) { - list.add(ContextMenuButtonItem( - onPressed: () async { - editableTextState.shareSelection(SelectionChangedCause.toolbar); - }, - type: ContextMenuButtonType.share, - )); + // list.add(ContextMenuButtonItem( + // onPressed: () async { + // editableTextState.shareSelection(SelectionChangedCause.toolbar); + // }, + // type: ContextMenuButtonType.share, + // )); } return AdaptiveTextSelectionToolbar.buttonItems( diff --git a/lib/ui/content/panel.dart b/lib/ui/content/panel.dart index 7773a00..eed8d03 100644 --- a/lib/ui/content/panel.dart +++ b/lib/ui/content/panel.dart @@ -87,6 +87,7 @@ class NetworkTabState extends State with SingleTickerProvi body: Padding( padding: const EdgeInsets.only(left: 20, right: 20, top: 10), child: TabBarView( + physics: const NeverScrollableScrollPhysics(), //禁止滑动 controller: _tabController, children: [ general(), diff --git a/lib/ui/desktop/left/favorite.dart b/lib/ui/desktop/left/favorite.dart index dcf7084..2976014 100644 --- a/lib/ui/desktop/left/favorite.dart +++ b/lib/ui/desktop/left/favorite.dart @@ -129,6 +129,7 @@ class _FavoriteItemState extends State<_FavoriteItem> { requestEdit(); }); }), + const PopupMenuDivider(height: 0.3), popupItem("删除收藏", onTap: () { widget.onRemove?.call(widget.request); }) diff --git a/lib/ui/desktop/left/history.dart b/lib/ui/desktop/left/history.dart index 14e030a..c91b2b8 100644 --- a/lib/ui/desktop/left/history.dart +++ b/lib/ui/desktop/left/history.dart @@ -257,7 +257,8 @@ class _HistoryState extends State<_HistoryWidget> { //获取请求 List requests = await storage.getRequests(item); var file = await File(result.path).create(); - Har.writeFile(requests, file, title: item.name); + await Har.writeFile(requests, file, title: item.name); + if (context.mounted) FlutterToastr.show("导出成功", context); Future.delayed(const Duration(seconds: 30), () => item.requests = null); } diff --git a/lib/ui/desktop/left/search_condition.dart b/lib/ui/desktop/left/search_condition.dart index 9ceaddc..a6f39ce 100644 --- a/lib/ui/desktop/left/search_condition.dart +++ b/lib/ui/desktop/left/search_condition.dart @@ -127,19 +127,19 @@ class SearchConditionsState extends State { onPressed: () { Navigator.pop(context); }, - child: const Text('取消')), + child: const Text('取消', style: TextStyle(fontSize: 14))), TextButton( onPressed: () { widget.onSearch?.call(SearchModel()); Navigator.pop(context); }, - child: const Text('清除搜索')), + child: const Text('清除搜索', style: TextStyle(fontSize: 14))), TextButton( onPressed: () { widget.onSearch?.call(searchModel); Navigator.pop(context); }, - child: const Text('确定')), + child: const Text('确定', style: TextStyle(fontSize: 14))), ], ) ], diff --git a/lib/utils/har.dart b/lib/utils/har.dart index d6223d5..d49cbc9 100644 --- a/lib/utils/har.dart +++ b/lib/utils/har.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:network_proxy/network/host_port.dart'; import 'package:network_proxy/network/http/http.dart'; +import 'package:network_proxy/network/http/http_headers.dart'; class Har { static int maxBodyLength = 1024 * 1024 * 4; @@ -37,6 +38,10 @@ class Har { 'serverIPAddress': request.response?.remoteAddress }; + //body已经解码 删除编码 + if (request.response?.headers.contentEncoding == 'br') { + request.response?.headers.remove(HttpHeaders.CONTENT_ENCODING); + } har['response'] = { "status": request.response?.status.code ?? 0, // 响应状态码 "statusText": request.response?.status.reasonPhrase ?? '', // 响应状态码描述 @@ -141,7 +146,7 @@ class Har { return { "mimeType": request.headers.contentType, // 请求体类型 "text": request.bodyAsString, // 请求体内容 - "params": request.bodyAsString, // 请求体内容 + "params": [], // 请求体内容 }; } return {