2021-11-17 23:11:54 +08:00
|
|
|
import{V as Q,W as se,P as l,X as de,r as d,o as f,b as S,a,w as t,e as _,t as O,c as R,n as q,F as M,p as n,Y as ue,Z as me,$ as ce,O as fe,N as ve,d as _e,x as D,y as E}from"./vendor.ee21a423.js";import{P as X,a as Y,b as ye,u as pe,x as he}from"./unitConvert.c16ab317.js";import{z as Pe}from"./custom.33a00f74.js";import{_ as W}from"./main.b335ea75.js";const ge={props:{result:{type:Object,required:!0},loading:{type:Boolean,required:!0}},components:{CloseOutlined:Q,ParamTable:X,ParamBody:Y,aceEditor:ye},setup(v){const{result:o}=se(v);let w=l("body"),e=l("format"),y=l("json"),L=l(""),c=l([]),x=l([]),u=l(""),p=l(""),h=l({}),P=l();const g=()=>{e.value==="preview"&&setTimeout(()=>{P.value&&P.value.contentDocument.write(u.value)},0)},k=()=>{if(u.value="",p.value="",v.result.data){if(h.value=v.result.data,v.result.data.headers){c.value=v.result.data.headers;let m=c.value.find(T=>T.name==="Content-Type");m&&m.value&&(m.value.indexOf("text/html")>=0?y.value="html":m.value.indexOf("text/plain")>=0?y.value="text":m.value.indexOf("application/json")>=0?y.value="json":m.value.indexOf("application/xml")>=0||m.value.indexOf("text/xml")>=0?y.value="xml":m.value.indexOf("application/javascript")>=0&&(y.value="javascript"),L.value=y.value)}if(v.result.data.cookies&&(x.value=v.result.data.cookies),v.result.data.data){u.value=v.result.data.data,p.value=v.result.data.data;try{y.value==="xml"?p.value=he(u.value):y.value==="json"?p.value=JSON.stringify(JSON.parse(u.value),null,4):y.value==="javascript"&&(p.value=JSON.stringify(u.value,null,4))}catch{p.value=v.result.data.data}}else{let m=`
|
2021-11-17 23:11:54 +08:00
|
|
|
`;u.value=m+JSON.stringify(v.result.data),p.value=m+JSON.stringify(v.result.data,null,4)}g()}};return k(),de(o,()=>k()),{activePage:w,bodyShowType:e,bodyShowTypeChange:g,unitConvert:pe,bodyShowFormatType:y,bodyShowFormatPreview:L,previewHtmlRef:P,resultData:h,resultHeaders:c,resultCookies:x,resultHeadersColumns:[{title:"KEY",dataIndex:"name"},{title:"VALUE",dataIndex:"value"}],resultCookiesColumns:[{title:"KEY",dataIndex:"name"},{title:"VALUE",dataIndex:"value"}],resultDataInit:m=>{m.setFontSize(16)},resultDataContentOrigin:u,resultDataContentFormat:p,resultDataConfig:{wrap:!0,readOnly:!0,autoScrollEditorIntoView:!0,enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,minLines:30,maxLines:30}}}},be={key:0,style:{"margin-bottom":"30px"}},xe={key:0,style:{"margin-bottom":"30px"}},ke={style:{"margin-bottom":"10px"}},Se=n("\u683C\u5F0F\u5316"),we=n("\u539F\u59CB\u503C"),Le=n("\u9884\u89C8"),Te=n("JSON"),Re=n("HTML"),Ce=n("XML"),Oe=n("JavaScript"),De=n("TEXT"),Ee={key:2},Ne={key:0,ref:"previewHtmlRef",width:"100%",height:"570px",style:{border:"0"}},Ue={class:"status-info-box"},qe=n(" \u72B6\u6001\u7801\uFF1A"),Ie=n(" \u8017\u65F6\uFF1A"),Je=n(" \u5927\u5C0F\uFF1A"),Ve={key:1},je={style:{color:"#f00"}},Ae={class:"status-info-box"},Ke=n(" \u8017\u65F6\uFF1A"),Fe={key:1,style:{"margin-top":"20px"}},Be={key:2,style:{"margin-top":"20px",color:"#aaa"}};function He(v,o,w,e,y,L){const c=d("a-radio-button"),x=d("a-radio-group"),u=d("a-select-option"),p=d("a-select"),h=d("ace-editor"),P=d("a-tab-pane"),g=d("a-table"),k=d("a-tabs"),C=d("a-skeleton"),m=d("a-spin"),T=d("a-empty");return w.result.data?(f(),S("div",be,[w.result.data.data?(f(),S("div",xe,[a(k,{activeKey:e.activePage,"onUpdate:activeKey":o[4]||(o[4]=i=>e.activePage=i),onTabClick:o[5]||(o[5]=()=>{}),style:{padding:"5px 10px 0"}},{rightExtra:t(()=>[_("span",Ue,[qe,_("span",null,O(e.resultData.status||"200"),1),Ie,_("span",null,O(e.unitConvert.formatSeconds(e.resultData.useTime||0)),1),Je,_("span",null,O(e.unitConvert.formatFileSize(e.resultData.contentLength||0)),1)])]),default:t(()=>[a(P,{tab:"Body",key:"body",forceRender:""},{default:t(()=>[_("div",ke,[a(x,{value:e.bodyShowType,"onUpdate:value":o[0]||(o[0]=i=>e.bodyShowType=i),onChange:e.bodyShowTypeChange,size:"small"},{default:t(()=>[a(c,{value:"format"},{default:t(()=>[Se]),_:1}),a(c,{value:"row"},{default:t(()=>[we]),_:1}),a(c,{value:"preview"},{default:t(()=>[Le]),_:1})]),_:1},8,["value","onChange"]),e.bodyShowType==="format"?(f(),R(p,{key:0,value:e.bodyShowFormatType,"onUpdate:value":o[1]||(o[1]=i=>e.bodyShowFormatType=i),size:"small",style:{"margin-left":"10px",width:"100px"}},{default:t(()=>[a(u,{value:"json"},{default:t(()=>[Te]),_:1}),a(u,{value:"html"},{default:t(()=>[Re]),_:1}),a(u,{value:"xml"},{default:t(()=>[Ce]),_:1}),a(u,{value:"javascript"},{default:t(()=>[Oe]),_:1}),a(u,{value:"text"},{default:t(()=>[De]),_:1})]),_:1},8,["value"])):q("",!0)]),e.bodyShowType==="format"?(f(),R(h,{key:0,value:e.resultDataContentFormat,"onUpdate:value":o[2]||(o[2]=i=>e.resultDataContentFormat=i),onInit:e.resultDataInit,lang:e.bodyShowFormatType,theme:"monokai",width:"100%",height:"100",options:e.resultDataConfig},null,8,["value","onInit","lang","options"])):e.bodyShowType==="row"?(f(),R(h,{key:1,value:e.resultDataContentOrigin,"onUpdate:value":o[3]||(o[3]=i=>e.resultDataContentOrigin=i),onInit:e.resultDataInit,lang:"text",theme:"chrome",width:"100%",height:"100",options:e.resultDataConfig},null,8,["value","onInit","options"])):e.bodyShowType==="preview"?(f(),S("div",Ee,[e.bodyShowFormatPreview==="html"?(f(),S("iframe",Ne,null,512)):(f(),S(M,{key:1},[n(O(e.resultDataContentOrigin),1)],64))])):q("",!0)]),_:1}),a(P,{tab:"Headers",key:"headers",forceRender:""},{default:t(()=>[a(g,{dataSource:e.resultHeaders,columns:e.resultHeadersColumns,size:"small",pagination:!1,scroll:{y:"300px"}},null,8,["dataSource","columns"])]),_:1}),a(P,{tab:"Cookies",key:"cookies",forceRender:""},{default:t(()=>[a(g,{dataSource:e.resultCookies,columns:e.resultCookiesColumns,size:"small",pagination:!1,scroll:{y:"300px"}},null,8,["data
|