From 00f196d0cc824c69db1f04f200aa4e2abc71e33c Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Sat, 10 Aug 2024 21:49:42 +0800 Subject: [PATCH] content-type video --- lib/network/channel.dart | 9 +++++---- lib/network/http/http.dart | 4 +++- lib/ui/component/utils.dart | 1 + lib/ui/content/body.dart | 9 +++++++++ lib/ui/desktop/left_menus/navigation.dart | 3 --- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/network/channel.dart b/lib/network/channel.dart index 1e067ca..64a8b55 100644 --- a/lib/network/channel.dart +++ b/lib/network/channel.dart @@ -309,11 +309,12 @@ class ChannelPipeline extends ChannelHandler { Channel? remoteChannel = channelContext.getAttribute(channel.id); //大body 不解析直接转发 - if (buffer.length > Codec.maxBodyLength) { - relay(channel, remoteChannel!); - handler.channelRead(channelContext, channel, buffer.bytes); - buffer.clear(); + if (buffer.length > Codec.maxBodyLength && handler is! RelayHandler) { logger.w("[$channel] forward large body"); + relay(channel, remoteChannel!); + var body = buffer.bytes; + buffer.clear(); + handler.channelRead(channelContext, channel, body); return; } diff --git a/lib/network/http/http.dart b/lib/network/http/http.dart index 7f01fbd..2ddfb2c 100644 --- a/lib/network/http/http.dart +++ b/lib/network/http/http.dart @@ -37,6 +37,7 @@ abstract class HttpMessage { "application/x-www-form-urlencoded": ContentType.formUrl, "form-data": ContentType.formData, "image": ContentType.image, + "video": ContentType.video, "application/json": ContentType.json }; @@ -195,6 +196,7 @@ enum ContentType { css, font, image, + video, http; static ContentType valueOf(String name) { @@ -203,7 +205,7 @@ enum ContentType { //是否是二进制 bool get isBinary { - return this == image || this == font; + return this == image || this == font || this == video; } } diff --git a/lib/ui/component/utils.dart b/lib/ui/component/utils.dart index a6e966b..ebc334c 100644 --- a/lib/ui/component/utils.dart +++ b/lib/ui/component/utils.dart @@ -11,6 +11,7 @@ const contentMap = { ContentType.html: Icons.html, ContentType.js: Icons.javascript, ContentType.image: Icons.image, + ContentType.video: Icons.video_call, ContentType.text: Icons.text_fields, ContentType.css: Icons.css, ContentType.font: Icons.font_download, diff --git a/lib/ui/content/body.dart b/lib/ui/content/body.dart index 8d1ddf8..d202d8d 100644 --- a/lib/ui/content/body.dart +++ b/lib/ui/content/body.dart @@ -358,6 +358,9 @@ class _BodyState extends State<_Body> { if (type == ViewType.image) { return Image.memory(Uint8List.fromList(message?.body ?? []), fit: BoxFit.none); } + if (type == ViewType.video) { + return const Center(child: Text("video not support preview")); + } if (type == ViewType.hex) { return SelectableText(message!.body!.map(intToHex).join(" "), contextMenuBuilder: contextMenu); } @@ -379,6 +382,11 @@ class Tabs { return tabs; } + if (contentType == ContentType.video) { + tabs.list.add(ViewType.hex); + return tabs; + } + if (contentType == ContentType.json) { tabs.list.add(ViewType.jsonText); } @@ -411,6 +419,7 @@ enum ViewType { jsonText("JSON Text"), html("HTML"), image("Image"), + video("Video"), css("CSS"), js("JavaScript"), hex("Hex"), diff --git a/lib/ui/desktop/left_menus/navigation.dart b/lib/ui/desktop/left_menus/navigation.dart index 57a1e88..dd2391f 100644 --- a/lib/ui/desktop/left_menus/navigation.dart +++ b/lib/ui/desktop/left_menus/navigation.dart @@ -47,9 +47,6 @@ class _LeftNavigationBarState extends State { @override Widget build(BuildContext context) { - widget.controller.addListener(() { - print('page: ${widget.controller.page}'); - }); return ValueListenableBuilder( valueListenable: widget.selectIndex,