From 9e7927984c7f9ac9dfb5a821734232383cac602e Mon Sep 17 00:00:00 2001 From: song_xiao_lin <63901989+song-xiao-lin@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:11:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9A=E4=BD=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=B8=B2=E6=9F=93=E5=92=8C=E7=BE=8E=E5=8C=96?= =?UTF-8?q?=20(#2316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/src/components/HTTPFlowDetail.tsx | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/app/renderer/src/main/src/components/HTTPFlowDetail.tsx b/app/renderer/src/main/src/components/HTTPFlowDetail.tsx index 0d4934ceab..fcb103bf53 100644 --- a/app/renderer/src/main/src/components/HTTPFlowDetail.tsx +++ b/app/renderer/src/main/src/components/HTTPFlowDetail.tsx @@ -1206,25 +1206,40 @@ export const HTTPFlowDetailRequestAndResponse: React.FC("utf-8") const [codeLoading, setCodeLoading] = useState(false) const [codeValue, setCodeValue] = useState("") - useEffect(() => { - if (flow) { - setCodeKey("utf-8") - getRemoteValue(RemoteGV.HistoryRequestEditorBeautify).then((res) => { - if (!!res) { - setReqTypeOptionVal(res) - } else { + useDebounceEffect( + () => { + if (flow) { + setCodeKey("utf-8") + const reqArr = highLightItem?.IsMatchRequest ? [highLightItem] : [] + const resArr = highLightItem ? (!highLightItem.IsMatchRequest ? [highLightItem] : []) : [] + if (reqArr.length) { setReqTypeOptionVal(undefined) - } - }) - getRemoteValue(RemoteGV.HistoryResponseEditorBeautify).then((res) => { - if (!!res) { - setResTypeOptionVal(res) } else { + getRemoteValue(RemoteGV.HistoryRequestEditorBeautify).then((res) => { + if (!!res) { + setReqTypeOptionVal(res) + } else { + setReqTypeOptionVal(undefined) + } + }) + } + + if (resArr.length) { setResTypeOptionVal(undefined) + } else { + getRemoteValue(RemoteGV.HistoryResponseEditorBeautify).then((res) => { + if (!!res) { + setResTypeOptionVal(res) + } else { + setResTypeOptionVal(undefined) + } + }) } - }) - } - }, [flow]) + } + }, + [flow, highLightItem], + {wait: 300} + ) // 响应额外按钮 const secondNodeResExtraBtn = () => { @@ -1487,9 +1502,12 @@ export const HTTPFlowDetailRequestAndResponse: React.FC - { - emiter.emit("onEditTag", JSON.stringify({id: flow.Id, historyId})) - }}> + { + emiter.emit("onEditTag", JSON.stringify({id: flow.Id, historyId})) + }} + > 编辑tag