diff --git a/app/renderer/src/main/src/components/HTTPFlowTable/HTTPFlowTable.tsx b/app/renderer/src/main/src/components/HTTPFlowTable/HTTPFlowTable.tsx index 050d19124f..9c6d3c9c79 100644 --- a/app/renderer/src/main/src/components/HTTPFlowTable/HTTPFlowTable.tsx +++ b/app/renderer/src/main/src/components/HTTPFlowTable/HTTPFlowTable.tsx @@ -3415,19 +3415,18 @@ export const HTTPFlowTable = React.memo((props) => { selectTypeList = ["mitm"] } } - const newParams = {...params, SourceType: selectTypeList.join(",")} - getHTTPFlowsFieldGroup(true, (t: FiltersItemProps[]) => { - let tagsList: string[] = [] - mitmHasParamsNamesArr.forEach((item) => { - if (t.findIndex((ele) => ele.label === item) !== -1) { - tagsList.push(item) - } - }) - setTagsFilter(tagsList) - newParams.Tags = tagsList + const newParams = {...params, SourceType: selectTypeList.join(","), FromPlugin: mitmHasParamsNames} + if (JSON.stringify(params.SourceType?.split(",") || [""]) === JSON.stringify(selectTypeList)) { setParams(newParams) - emiter.emit("onHistorySourceTypeToMitm", newParams.SourceType) - }) + setTimeout(() => { + updateData() + }, 20) + } else { + setParams(newParams) + setTimeout(() => { + emiter.emit("onHistorySourceTypeToMitm", newParams.SourceType) + }, 20) + } }) // mitm页面带参数插件跳转过来 diff --git a/app/renderer/src/main/src/pages/mitm/MITMPage.tsx b/app/renderer/src/main/src/pages/mitm/MITMPage.tsx index d2bf37f52b..c7c6e8d89b 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMPage.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMPage.tsx @@ -92,6 +92,7 @@ export const MITMPage: React.FC = (props) => { const [statusCards, setStatusCards] = useState([]) const [downstreamProxyStr, setDownstreamProxyStr] = useState("") const [showPluginHistoryList, setShowPluginHistoryList] = useState([]) + const [tempShowPluginHistory, setTempShowPluginHistory] = useState("") // 检测当前劫持状态 useEffect(() => { // 用于启动 MITM 开始之后,接受开始成功之后的第一个消息,如果收到,则认为说 MITM 启动成功了 @@ -342,6 +343,8 @@ export const MITMPage: React.FC = (props) => { onIsHasParams={setIsHasParams} showPluginHistoryList={showPluginHistoryList} setShowPluginHistoryList={setShowPluginHistoryList} + tempShowPluginHistory={tempShowPluginHistory} + setTempShowPluginHistory={setTempShowPluginHistory} /> ) } @@ -456,6 +459,8 @@ interface MITMServerProps { onIsHasParams: (isHasParams: boolean) => void showPluginHistoryList: string[] setShowPluginHistoryList: (l: string[]) => void + tempShowPluginHistory?: string + setTempShowPluginHistory?: (t: string) => void } export const MITMServer: React.FC = React.memo((props) => { const { @@ -469,7 +474,9 @@ export const MITMServer: React.FC = React.memo((props) => { isHasParams, onIsHasParams = () => {}, showPluginHistoryList, - setShowPluginHistoryList + tempShowPluginHistory, + setShowPluginHistoryList, + setTempShowPluginHistory } = props const [openTabsFlag, setOpenTabsFlag] = useState(true) @@ -503,24 +510,24 @@ export const MITMServer: React.FC = React.memo((props) => { () => { if (status === "idle") { const CHECK_CACHE_LIST_DATA = "CHECK_CACHE_LIST_DATA" - getRemoteValue(CHECK_CACHE_LIST_DATA) - .then((data: string) => { - getRemoteValue(CONST_DEFAULT_ENABLE_INITIAL_PLUGIN).then((is) => { - if (!!data && !!is) { - const cacheData: string[] = JSON.parse(data) - if (cacheData.length) { - onIsHasParams(false) - } + getRemoteValue(CHECK_CACHE_LIST_DATA).then((data: string) => { + getRemoteValue(CONST_DEFAULT_ENABLE_INITIAL_PLUGIN).then((is) => { + if (!!data && !!is) { + const cacheData: string[] = JSON.parse(data) + if (cacheData.length) { + onIsHasParams(false) } else { - if (noParamsCheckList.length) { - onIsHasParams(false) - } else { - onIsHasParams(true) - } + onIsHasParams(true) } - }) + } else { + if (noParamsCheckList.length) { + onIsHasParams(false) + } else { + onIsHasParams(true) + } + } }) - + }) } }, [status, noParamsCheckList], @@ -779,7 +786,9 @@ export const MITMServer: React.FC = React.memo((props) => { onSetOpenTabsFlag={setOpenTabsFlag} onSetLoadedPluginLen={setLoadedPluginLen} showPluginHistoryList={showPluginHistoryList} + tempShowPluginHistory={tempShowPluginHistory} setShowPluginHistoryList={setShowPluginHistoryList} + setTempShowPluginHistory={setTempShowPluginHistory} /> ) } @@ -818,6 +827,7 @@ export const MITMServer: React.FC = React.memo((props) => { loadedPluginLen={loadedPluginLen} onSelectAll={onSelectAll} setShowPluginHistoryList={setShowPluginHistoryList} + setTempShowPluginHistory={setTempShowPluginHistory} /> ) } diff --git a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMHijackedContent.tsx b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMHijackedContent.tsx index b643529814..29191cfad5 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMHijackedContent.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMHijackedContent.tsx @@ -35,6 +35,7 @@ interface MITMHijackedContentProps { loadedPluginLen: number onSelectAll: (e: boolean) => void setShowPluginHistoryList: (l: string[]) => void + setTempShowPluginHistory?: (t: string) => void } const MITMHijackedContent: React.FC = React.memo((props) => { @@ -48,7 +49,8 @@ const MITMHijackedContent: React.FC = React.memo((prop downstreamProxyStr, loadedPluginLen, onSelectAll, - setShowPluginHistoryList + setShowPluginHistoryList, + setTempShowPluginHistory } = props // 自动转发 与 劫持响应的自动设置 const [autoForward, setAutoForward, getAutoForward] = useGetState<"manual" | "log" | "passive">("log") @@ -295,6 +297,7 @@ const MITMHijackedContent: React.FC = React.memo((prop forward() } setShowPluginHistoryList([]) + setTempShowPluginHistory && setTempShowPluginHistory("") setSourceType("mitm") } catch (e) { console.info(e) diff --git a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginHijackContent.tsx b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginHijackContent.tsx index 6e56478638..12101c6942 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginHijackContent.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginHijackContent.tsx @@ -26,6 +26,7 @@ import styles from "./MITMServerHijacking.module.scss" import classNames from "classnames" import {RemoteGV} from "@/yakitGV" import {YakitRadioButtons} from "@/components/yakitUI/YakitRadioButtons/YakitRadioButtons" +import emiter from "@/utils/eventBus/eventBus" const {ipcRenderer} = window.require("electron") @@ -62,6 +63,8 @@ interface MITMPluginHijackContentProps { onSetLoadedPluginLen: (s: number) => void showPluginHistoryList: string[] setShowPluginHistoryList: (l: string[]) => void + tempShowPluginHistory?: string + setTempShowPluginHistory?: (t: string) => void } const HotLoadDefaultData: YakScript = { Id: 0, @@ -108,6 +111,8 @@ export const MITMPluginHijackContent: React.FC = ( onSetLoadedPluginLen, showPluginHistoryList, setShowPluginHistoryList, + tempShowPluginHistory = "", + setTempShowPluginHistory } = props const [curTabKey, setCurTabKey] = useState("all") @@ -147,6 +152,11 @@ export const MITMPluginHijackContent: React.FC = ( // 是否允许获取默认勾选值 const isDefaultCheck = useRef(false) + const tempShowPluginHistoryRef = useRef(tempShowPluginHistory) + useEffect(() => { + tempShowPluginHistoryRef.current = tempShowPluginHistory + }, [tempShowPluginHistory]) + // 初始化加载 hooks,设置定时更新 hooks 状态 useEffect(() => { updateHooks() @@ -222,6 +232,10 @@ export const MITMPluginHijackContent: React.FC = ( } } }) + if (tempShowPluginHistoryRef.current && hasParamsCheckArr.includes(tempShowPluginHistoryRef.current)) { + setShowPluginHistoryList([tempShowPluginHistoryRef.current]) + emiter.emit("onHasParamsJumpHistory", [tempShowPluginHistoryRef.current].join(",")) + } setHasParamsCheckList([...hasParamsCheckArr]) setNoParamsCheckList([...noParamsCheckArr]) }) @@ -499,6 +513,7 @@ export const MITMPluginHijackContent: React.FC = ( hasParamsCheckList={hasParamsCheckList} showPluginHistoryList={showPluginHistoryList} setShowPluginHistoryList={setShowPluginHistoryList} + setTempShowPluginHistory={setTempShowPluginHistory} curTabKey={curTabKey} /> )} @@ -590,6 +605,7 @@ export const MITMPluginHijackContent: React.FC = ( showPluginHistoryList={showPluginHistoryList} setShowPluginHistoryList={setShowPluginHistoryList} curTabKey={curTabKey} + setTempShowPluginHistory={setTempShowPluginHistory} /> diff --git a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginLocalList.tsx b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginLocalList.tsx index 4f2d7f4aaa..1da8722bd6 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginLocalList.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMPluginLocalList.tsx @@ -92,6 +92,7 @@ interface MITMPluginLocalListProps { isHasParams: boolean showPluginHistoryList?: string[] setShowPluginHistoryList?: (l: string[]) => void + setTempShowPluginHistory?: (t: string) => void hasParamsCheckList: string[] curTabKey?: string } @@ -122,6 +123,7 @@ export const MITMPluginLocalList: React.FC = React.mem isHasParams, showPluginHistoryList = [], setShowPluginHistoryList = () => {}, + setTempShowPluginHistory, hasParamsCheckList, curTabKey = "" } = props @@ -272,6 +274,7 @@ export const MITMPluginLocalList: React.FC = React.mem showPluginHistoryList={showPluginHistoryList} setShowPluginHistoryList={setShowPluginHistoryList} hasParamsCheckList={hasParamsCheckList} + setTempShowPluginHistory={setTempShowPluginHistory} // 劫持启动前 defaultPlugins={noParamsCheckList} setDefaultPlugins={setNoParamsCheckList} diff --git a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMServerHijacking.tsx b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMServerHijacking.tsx index 870fe00023..ae04c13122 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMServerHijacking.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMServerHijacking/MITMServerHijacking.tsx @@ -52,6 +52,8 @@ export interface MITMServerHijackingProp { onIsHasParams: (isHasParams: boolean) => void showPluginHistoryList: string[] setShowPluginHistoryList: (l: string[]) => void + tempShowPluginHistory: string + setTempShowPluginHistory: (t: string) => void } const {ipcRenderer} = window.require("electron") @@ -82,7 +84,9 @@ export const MITMServerHijacking: React.FC = (props) => isHasParams, onIsHasParams, showPluginHistoryList, - setShowPluginHistoryList + setShowPluginHistoryList, + tempShowPluginHistory, + setTempShowPluginHistory } = props const {queryPagesDataById, removePagesDataCacheById} = usePageInfo( @@ -142,6 +146,7 @@ export const MITMServerHijacking: React.FC = (props) => .then(() => { onIsHasParams(false) setShowPluginHistoryList([]) + setTempShowPluginHistory("") setStatus("idle") resolve("ok") }) @@ -252,6 +257,8 @@ export const MITMServerHijacking: React.FC = (props) => downstreamProxyStr={downstreamProxyStr} showPluginHistoryList={showPluginHistoryList} setShowPluginHistoryList={setShowPluginHistoryList} + tempShowPluginHistory={tempShowPluginHistory} + setTempShowPluginHistory={setTempShowPluginHistory} /> loading...}> diff --git a/app/renderer/src/main/src/pages/mitm/MITMYakScriptLoader.tsx b/app/renderer/src/main/src/pages/mitm/MITMYakScriptLoader.tsx index a38013e54e..287df8c434 100644 --- a/app/renderer/src/main/src/pages/mitm/MITMYakScriptLoader.tsx +++ b/app/renderer/src/main/src/pages/mitm/MITMYakScriptLoader.tsx @@ -43,6 +43,7 @@ export const MITMYakScriptLoader = React.memo((p: MITMYakScriptLoaderProps) => { showEditor, showPluginHistoryList = [], setShowPluginHistoryList = () => {}, + setTempShowPluginHistory, hasParamsCheckList, curTabKey } = p @@ -127,12 +128,15 @@ export const MITMYakScriptLoader = React.memo((p: MITMYakScriptLoaderProps) => { const saveParams: CustomPluginExecuteFormValue = {...values} const saveParasmArr: YakExecutorParam[] = [] Object.keys(saveParams).forEach((key) => { - saveParasmArr.push({Key: key, Value: saveParams[key]}) + if (saveParams[key] !== false) { + saveParasmArr.push({Key: key, Value: saveParams[key]}) + } }) setRemoteValue("mitm_has_params_" + i.ScriptName, JSON.stringify(saveParasmArr)) if (submitFlag) { clearMITMPluginCache() onSubmitYakScriptId(script.Id, saveParasmArr) + setTempShowPluginHistory && setTempShowPluginHistory(i.ScriptName) } m.destroy() } @@ -223,12 +227,24 @@ export const MITMYakScriptLoader = React.memo((p: MITMYakScriptLoaderProps) => { [style["history-icon-light"]]: showPluginHistoryList.includes(i.ScriptName) })} onClick={() => { + // 多个 + // let arr = [...showPluginHistoryList] + // if (arr.includes(i.ScriptName)) { + // arr = arr.filter((item) => item !== i.ScriptName) + // } else { + // arr.push(i.ScriptName) + // } + + // 单个 let arr = [...showPluginHistoryList] if (arr.includes(i.ScriptName)) { arr = arr.filter((item) => item !== i.ScriptName) } else { - arr.push(i.ScriptName) + arr = [i.ScriptName] } + + setTempShowPluginHistory && setTempShowPluginHistory("") + setShowPluginHistoryList(arr) emiter.emit("onHasParamsJumpHistory", arr.join(",")) }} @@ -343,6 +359,7 @@ export interface MITMYakScriptLoaderProps { showEditor: boolean showPluginHistoryList?: string[] setShowPluginHistoryList?: (l: string[]) => void + setTempShowPluginHistory?: (l: string) => void hasParamsCheckList: string[] curTabKey: string }