diff --git a/lib/storage/favorites.dart b/lib/storage/favorites.dart index fe254a4..e4700b3 100644 --- a/lib/storage/favorites.dart +++ b/lib/storage/favorites.dart @@ -96,7 +96,7 @@ class Favorite { name: json['name'], response: json['response'] == null ? null : HttpResponse.fromJson(json['response'])); } - toJson() { + Map toJson() { return { 'name': name, 'request': request.toJson(), diff --git a/lib/ui/content/body.dart b/lib/ui/content/body.dart index c675ece..dc7bf2f 100644 --- a/lib/ui/content/body.dart +++ b/lib/ui/content/body.dart @@ -607,8 +607,8 @@ class HexViewer extends StatelessWidget { final StringBuffer buffer = StringBuffer(); for (int i = 0; i < data.length; i += bytesPerRow) { // Address - buffer.write(i.toRadixString(16).padLeft(8, '0')); - buffer.write(' '); + // buffer.write(i.toRadixString(16).padLeft(8, '0')); + // buffer.write(' '); // Hex values for (int j = 0; j < bytesPerRow; j++) { diff --git a/lib/ui/content/web_socket.dart b/lib/ui/content/web_socket.dart index d004d75..f211c7d 100644 --- a/lib/ui/content/web_socket.dart +++ b/lib/ui/content/web_socket.dart @@ -141,40 +141,35 @@ class _PreviewDialogState extends State<_PreviewDialog> { child: DefaultTabController( length: tabs.length, initialIndex: tabIndex, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TabBar( - tabs: tabs, - onTap: (index) { - setState(() { - tabIndex = index; - }); - }, - ), - Expanded( - child: TabBarView( - children: [ - if (isJsonText(widget.bytes)) - SingleChildScrollView(padding: const EdgeInsets.all(8.0), child: jsonText()), - if (isJsonText(widget.bytes)) - SingleChildScrollView(padding: const EdgeInsets.all(8.0), child: jsonView()), - // TEXT - SingleChildScrollView( - padding: const EdgeInsets.all(8), - child: SelectableText(safeTextPreview(widget.bytes)), - ), - - // HEX - SingleChildScrollView( - padding: const EdgeInsets.all(8), - child: SelectableText(widget.bytes.map(intToHex).join(" ")), - ), - ], + child: Column(mainAxisSize: MainAxisSize.min, children: [ + TabBar( + tabs: tabs, + onTap: (index) { + setState(() { + tabIndex = index; + }); + }, + ), + Expanded( + child: TabBarView(children: [ + if (isJsonText(widget.bytes)) + SingleChildScrollView(padding: const EdgeInsets.all(8.0), child: jsonText()), + if (isJsonText(widget.bytes)) + SingleChildScrollView(padding: const EdgeInsets.all(8.0), child: jsonView()), + // TEXT + SingleChildScrollView( + padding: const EdgeInsets.all(8), + child: SelectableText(safeTextPreview(widget.bytes)), ), - ), - ], - ), + + // HEX + SingleChildScrollView( + padding: const EdgeInsets.all(8), + child: SelectableText(widget.bytes.map(intToHex).join(" ")), + ), + ]), + ), + ]), ), ), actions: [ diff --git a/lib/ui/desktop/left_menus/favorite.dart b/lib/ui/desktop/left_menus/favorite.dart index 9c3b9fe..7e30e2c 100644 --- a/lib/ui/desktop/left_menus/favorite.dart +++ b/lib/ui/desktop/left_menus/favorite.dart @@ -150,7 +150,7 @@ class _FavoriteItemState extends State<_FavoriteItem> { } ///右键菜单 - menu(LongPressDownDetails details, HttpRequest request) { + void menu(LongPressDownDetails details, HttpRequest request) { showContextMenu( context, details.globalPosition, @@ -191,7 +191,7 @@ class _FavoriteItemState extends State<_FavoriteItem> { } //显示高级重发 - showCustomRepeat(HttpRequest request) async { + Future showCustomRepeat(HttpRequest request) async { var prefs = await SharedPreferences.getInstance(); if (!mounted) return; @@ -202,8 +202,9 @@ class _FavoriteItemState extends State<_FavoriteItem> { }); } - onRepeat(HttpRequest request) { + void onRepeat(HttpRequest request) { var httpRequest = request.copy(uri: request.requestUrl); + var proxyInfo = widget.panel.proxyServer.isRunning ? ProxyInfo.of("127.0.0.1", widget.panel.proxyServer.port) : null; HttpClients.proxyRequest(httpRequest, proxyInfo: proxyInfo); @@ -218,7 +219,7 @@ class _FavoriteItemState extends State<_FavoriteItem> { } //重命名 - rename(Favorite item) { + void rename(Favorite item) { String? name = item.name; showDialog( context: context, @@ -247,7 +248,7 @@ class _FavoriteItemState extends State<_FavoriteItem> { } ///请求编辑 - requestEdit(HttpRequest request) async { + Future requestEdit(HttpRequest request) async { var size = MediaQuery.of(context).size; var ratio = 1.0; if (Platform.isWindows) { diff --git a/lib/ui/desktop/left_menus/history.dart b/lib/ui/desktop/left_menus/history.dart index f24ce04..f5cc5ee 100644 --- a/lib/ui/desktop/left_menus/history.dart +++ b/lib/ui/desktop/left_menus/history.dart @@ -267,7 +267,7 @@ class _HistoryListState extends State<_HistoryListWidget> { onTap: () => toRequestsView(item))); } - toRequestsView(HistoryItem item) { + void toRequestsView(HistoryItem item) { Navigator.pushNamed(context, "/request_list", arguments: {'item': item}).whenComplete(() async { if (item != widget.historyTask.history && item.requests != null && item.requestLength != item.requests?.length) { await widget.storage.flushRequests(item, item.requests!); @@ -278,7 +278,7 @@ class _HistoryListState extends State<_HistoryListWidget> { } //重命名 - renameHistory(HistoryStorage storage, HistoryItem item) { + void renameHistory(HistoryStorage storage, HistoryItem item) { String name = item.name; showDialog( context: context, @@ -311,7 +311,7 @@ class _HistoryListState extends State<_HistoryListWidget> { } //导出har - export(HistoryItem item) async { + Future export(HistoryItem item) async { //文件名称 String fileName = '${item.name.contains("ProxyPin") ? '' : 'ProxyPin'}${item.name}.har'.replaceAll(" ", "_").replaceAll(":", "_"); diff --git a/lib/ui/desktop/request/request.dart b/lib/ui/desktop/request/request.dart index 971cabe..fc692dd 100644 --- a/lib/ui/desktop/request/request.dart +++ b/lib/ui/desktop/request/request.dart @@ -318,7 +318,7 @@ class _RequestWidgetState extends State { } //显示高级重发 - showCustomRepeat(HttpRequest request) async { + Future showCustomRepeat(HttpRequest request) async { var prefs = await SharedPreferences.getInstance(); if (!mounted) return; @@ -329,7 +329,7 @@ class _RequestWidgetState extends State { }); } - onRepeat(HttpRequest httpRequest) { + void onRepeat(HttpRequest httpRequest) { var request = httpRequest.copy(uri: httpRequest.requestUrl); var proxyInfo = widget.proxyServer.isRunning ? ProxyInfo.of("127.0.0.1", widget.proxyServer.port) : null; HttpClients.proxyRequest(request, proxyInfo: proxyInfo); diff --git a/lib/utils/har.dart b/lib/utils/har.dart index 49abdc7..613921c 100644 --- a/lib/utils/har.dart +++ b/lib/utils/har.dart @@ -186,13 +186,13 @@ class Har { if (request.contentType == ContentType.formData || request.contentType == ContentType.formUrl) { return { "mimeType": request.headers.contentType, // 请求体类型 - "text": request.bodyAsString, // 请求体内容 + "text": request.body == null ? null : String.fromCharCodes(request.body!), // 请求体内容 "params": [], // 请求体内容 }; } return { "mimeType": request.headers.contentType, // 请求体类型 - "text": request.bodyAsString, // 请求体内容 + "text": request.body == null ? null : String.fromCharCodes(request.body!), // 请求体内容 }; } diff --git a/lib/utils/num.dart b/lib/utils/num.dart index 39f0864..7c62faa 100644 --- a/lib/utils/num.dart +++ b/lib/utils/num.dart @@ -21,5 +21,5 @@ int hexToInt(String hex) { //int ---> hex String intToHex(int i) { - return i.toRadixString(16).padLeft(2, '0').toUpperCase(); + return i.toRadixString(16).padLeft(2, '0'); }