diff --git a/lib/network/components/request_rewrite.dart b/lib/network/components/request_rewrite.dart index cc812c6..a24e87a 100644 --- a/lib/network/components/request_rewrite.dart +++ b/lib/network/components/request_rewrite.dart @@ -135,7 +135,7 @@ class RequestRewriteInterceptor extends Interceptor { } } - _updateRequest(HttpRequest request, RewriteItem item) { + Future _updateRequest(HttpRequest request, RewriteItem item) async { var paramTypes = [RewriteType.addQueryParam, RewriteType.removeQueryParam, RewriteType.updateQueryParam]; if (paramTypes.contains(item.type)) { @@ -187,7 +187,7 @@ class RequestRewriteInterceptor extends Interceptor { return; } - _updateMessage(request, item); + await _updateMessage(request, item); } //修改消息 diff --git a/lib/ui/content/body.dart b/lib/ui/content/body.dart index bf7d678..15b4977 100644 --- a/lib/ui/content/body.dart +++ b/lib/ui/content/body.dart @@ -481,10 +481,7 @@ class _BodyState extends State<_Body> { return const Center(child: Text("video not support preview")); } if (type == ViewType.hex) { - return HighlightTextWidget( - text: message!.body!.map(intToHex).join(" "), - searchController: widget.searchController, - contextMenuBuilder: contextMenu); + return HexViewer(data: Uint8List.fromList(message!.body!)); } if (type == ViewType.formUrl) { @@ -589,3 +586,54 @@ enum ViewType { return null; } } + +class HexViewer extends StatelessWidget { + final Uint8List data; + final int bytesPerRow; + + const HexViewer({super.key, required this.data, this.bytesPerRow = 16}); + + @override + Widget build(BuildContext context) { + return SelectableText( + _formatHex(data, bytesPerRow), + style: const TextStyle(fontFamily: 'Courier', fontSize: 12), + ); + } + + String _formatHex(Uint8List data, int bytesPerRow) { + final StringBuffer buffer = StringBuffer(); + for (int i = 0; i < data.length; i += bytesPerRow) { + // Address + buffer.write(i.toRadixString(16).padLeft(8, '0')); + buffer.write(' '); + + // Hex values + for (int j = 0; j < bytesPerRow; j++) { + if (i + j < data.length) { + buffer.write(data[i + j].toRadixString(16).padLeft(2, '0')); + } else { + buffer.write(' '); + } + buffer.write(' '); + } + + buffer.write(' '); + + // ASCII representation + for (int j = 0; j < bytesPerRow; j++) { + if (i + j < data.length) { + final byte = data[i + j]; + if (byte >= 32 && byte <= 126) { + buffer.write(String.fromCharCode(byte)); + } else { + buffer.write('.'); + } + } + } + + buffer.writeln(); + } + return buffer.toString(); + } +} diff --git a/lib/ui/launch/launch.dart b/lib/ui/launch/launch.dart index 1973783..d537653 100644 --- a/lib/ui/launch/launch.dart +++ b/lib/ui/launch/launch.dart @@ -102,7 +102,11 @@ class _SocketLaunchState extends State with WindowListener, Widget windowManager.setPreventClose(false); await windowManager.destroy(); - await SystemNavigator.pop(); + try { + await SystemNavigator.pop(animated: true).timeout(Duration(milliseconds: 150)); + } catch (e) { + // + } exit(0); } diff --git a/lib/ui/mobile/mobile.dart b/lib/ui/mobile/mobile.dart index 28ac7e0..b3755db 100644 --- a/lib/ui/mobile/mobile.dart +++ b/lib/ui/mobile/mobile.dart @@ -304,7 +304,7 @@ class MobileHomeState extends State implements EventListener, Li }); } - showAlertDialog(String title, String content, Function onClose) { + void showAlertDialog(String title, String content, Function onClose) { showDialog( context: context, barrierDismissible: false, diff --git a/lib/utils/curl.dart b/lib/utils/curl.dart index 4ad3666..c2c42e4 100644 --- a/lib/utils/curl.dart +++ b/lib/utils/curl.dart @@ -127,9 +127,9 @@ class Curl { if (i + 1 < parts.length) { data = parts[++i]; } - } else if (!part.startsWith('-') && part.startsWith("http")) { + } else if (url == null && !part.startsWith('-') && part.contains("http")) { // 解析请求 URL - url = part; + url = part.replaceAll("'", "").replaceAll('"', ''); } else if ("--http2" == part) { // protocolVersion = "HTTP2"; }