2023-02-04 17:15:43 +08:00
|
|
|
import{aa as ie,ab as xe,y as r,N as ke,r as u,o as y,b as T,a,w as t,e as h,t as q,c as I,k as F,F as de,m as c,ac as Le,ad as Oe,u as ue,Q as J,X as j,d as De,B as ce,v as Te,W as Ce}from"./vendor.627eef95.js";import{D as Re,s as me}from"./DocContent.544f7edd.js";import{m as Ie}from"./index.a17fca00.js";import{P as fe,a as ve,u as Ne,x as qe}from"./unitConvert.ebb1c2d4.js";import{g as Je,z as je}from"./custom.e03d703e.js";import{a as Ee}from"./index.12ebc7b1.js";import{_ as Z}from"./main.2b6ab185.js";import"./logUtil.8ec1c7d7.js";const Ue={props:{result:{type:Object,required:!0},loading:{type:Boolean,required:!0}},components:{CloseOutlined:ie,ParamTable:fe,ParamBody:ve,aceEditor:Ee},setup(n){const{result:l}=xe(n);let w=r("body"),e=r("format"),_=r("json"),C=r(""),v=r([]),P=r([]),i=r(""),m=r(""),b=r({}),g=r();const d=()=>{e.value==="preview"&&setTimeout(()=>{g.value&&g.value.contentDocument.write(i.value)},0)},k=()=>{if(i.value="",m.value="",n.result.data){if(b.value=n.result.data,n.result.data.headers){v.value=n.result.data.headers;let f=v.value.find(O=>O.name==="Content-Type");f&&f.value&&(f.value.indexOf("text/html")>=0?_.value="html":f.value.indexOf("text/plain")>=0?_.value="text":f.value.indexOf("application/json")>=0?_.value="json":f.value.indexOf("application/xml")>=0||f.value.indexOf("text/xml")>=0?_.value="xml":f.value.indexOf("application/javascript")>=0&&(_.value="javascript"),C.value=_.value)}if(n.result.data.cookies&&(P.value=n.result.data.cookies),n.result.data.data||n.result.data.status===200){m.value=n.result.data.data,i.value=n.result.data.data;try{_.value==="xml"?m.value=qe(i.value):_.value==="json"?m.value=JSON.stringify(JSON.parse(i.value),null,4):_.value==="javascript"&&(m.value=JSON.stringify(i.value,null,4))}catch{m.value=n.result.data.data}}else{let f=`
|
2022-01-30 14:49:39 +08:00
|
|
|
`;i.value=f+JSON.stringify(n.result.data),m.value=f+JSON.stringify(n.result.data,null,4)}d()}};return k(),ke(l,()=>k()),{activePage:w,bodyShowType:e,bodyShowTypeChange:d,unitConvert:Ne,bodyShowFormatType:_,bodyShowFormatPreview:C,previewHtmlRef:g,resultData:b,resultHeaders:v,resultCookies:P,resultHeadersColumns:[{title:"KEY",dataIndex:"name"},{title:"VALUE",dataIndex:"value"}],resultCookiesColumns:[{title:"KEY",dataIndex:"name"},{title:"VALUE",dataIndex:"value"}],resultDataInit:f=>{f.setFontSize(16)},resultDataContentOrigin:i,resultDataContentFormat:m,resultDataConfig:{wrap:!0,readOnly:!0,autoScrollEditorIntoView:!0,enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,minLines:30,maxLines:30}}}},Fe={key:0,style:{"margin-bottom":"30px"}},Ke={key:0,style:{"margin-bottom":"30px"}},Ve={style:{"margin-bottom":"10px"}},Ae=c("\u683C\u5F0F\u5316"),Be=c("\u539F\u59CB\u503C"),Me=c("\u9884\u89C8"),He=c("JSON"),ze=c("HTML"),Qe=c("XML"),Ge=c("JavaScript"),Xe=c("TEXT"),Ye={key:2},We={key:0,ref:"previewHtmlRef",width:"100%",height:"570px",style:{border:"0"}},Ze={class:"status-info-box"},$e=c(" \u72B6\u6001\u7801\uFF1A"),ea=c(" \u8017\u65F6\uFF1A"),aa=c(" \u5927\u5C0F\uFF1A"),ta={key:1},oa={style:{color:"#f00"}},ra={class:"status-info-box"},na=c(" \u8017\u65F6\uFF1A"),la={key:1,style:{"margin-top":"20px"}},sa={key:2,style:{"margin-top":"20px",color:"#aaa"}};function ia(n,l,w,e,_,C){const v=u("a-radio-button"),P=u("a-radio-group"),i=u("a-select-option"),m=u("a-select"),b=u("ace-editor"),g=u("a-tab-pane"),d=u("a-table"),k=u("a-divider"),R=u("a-tabs"),f=u("a-skeleton"),O=u("a-spin"),S=u("a-empty");return w.result.data?(y(),T("div",Fe,[w.result.data.data||w.result.data.status===200?(y(),T("div",Ke,[a(R,{activeKey:e.activePage,"onUpdate:activeKey":l[4]||(l[4]=x=>e.activePage=x),onTabClick:l[5]||(l[5]=()=>{}),style:{padding:"5px 10px 0"}},{rightExtra:t(()=>[h("span",Ze,[$e,h("span",null,q(e.resultData.status||"200"),1),a(k,{type:"vertical"}),ea,h("span",null,q(e.unitConvert.formatSeconds(e.resultData.useTime||0)),1),a(k,{type:"vertical"}),aa,h("span",null,q(e.unitConvert.formatFileSize(e.resultData.contentLength||0)),1)])]),default:t(()=>[a(g,{tab:"Body",key:"body",forceRender:""},{default:t(()=>[h("div",Ve,[a(P,{value:e.bodyShowType,"onUpdate:value":l[0]||(l[0]=x=>e.bodyShowType=x),onChange:e.bodyShowTypeChange,size:"small"},{default:t(()=>[a(v,{value:"format"},{default:t(()=>[Ae]),_:1}),a(v,{value:"row"},{default:t(()=>[Be]),_:1}),a(v,{value:"preview"},{default:t(()=>[Me]),_:1})]),_:1},8,["value","onChange"]),e.bodyShowType==="format"?(y(),I(m,{key:0,value:e.bodyShowFormatType,"onUpdate:value":l[1]||(l[1]=x=>e.bodyShowFormatType=x),size:"small",style:{"margin-left":"10px",width:"100px"}},{default:t(()=>[a(i,{value:"json"},{default:t(()=>[He]),_:1}),a(i,{value:"html"},{default:t(()=>[ze]),_:1}),a(i,{value:"xml"},{default:t(()=>[Qe]),_:1}),a(i,{value:"javascript"},{default:t(()=>[Ge]),_:1}),a(i,{value:"text"},{default:t(()=>[Xe]),_:1})]),_:1},8,["value"])):F("",!0)]),e.bodyShowType==="format"?(y(),I(b,{key:0,value:e.resultDataContentFormat,"onUpdate:value":l[2]||(l[2]=x=>e.resultDataContentFormat=x),onInit:e.resultDataInit,lang:e.bodyShowFormatType,theme:"monokai",width:"100%",height:"100",options:e.resultDataConfig},null,8,["value","onInit","lang","options"])):e.bodyShowType==="row"?(y(),I(b,{key:1,value:e.resultDataContentOrigin,"onUpdate:value":l[3]||(l[3]=x=>e.resultDataContentOrigin=x),onInit:e.resultDataInit,lang:"text",theme:"chrome",width:"100%",height:"100",options:e.resultDataConfig},null,8,["value","onInit","options"])):e.bodyShowType==="preview"?(y(),T("div",Ye,[e.bodyShowFormatPreview==="html"?(y(),T("iframe",We,null,512)):(y(),T(de,{key:1},[c(q(e.resultDataContentOrigin),1)],64))])):F("",!0)]),_:1}),a(g,{tab:"Headers",key:"headers",forceRender:""},{default:t(()=>[a(d,{dataSource:e.resultHeaders,columns:e.resultHeadersColumns,size:"small",pagination:!1,scroll:{y:"300px"}},null,8,["dataSource","columns"])]),_:1}),a(g,{tab:"Cookies",key:"cookies",forceRender:""},{default:t(()=>[a(d,{dataSource:e.resultCookies
|