import{g as N,r as P}from"./apiConfig.09b7ec3b.js";import{_ as k}from"./param-studio.vue_vue_type_script_setup_true_lang.e008bef0.js";import{d as S,h as m,Y as O,ak as J,r as p,o as c,f as T,w as s,a as o,b as n,c as V,H as b,l as A}from"./index.e3896b23.js";const j={key:0},$=o("b",null,"token \u7533\u8BF7\uFF1A",-1),I=[$],z=o("br",null,null,-1),G={key:2},H=A("\u83B7\u53D6token"),K=o("br",null,null,-1),L=o("br",null,null,-1),M=o("div",null,[o("b",null,"\u8BF7\u6C42\u5730\u5740\uFF1A")],-1),Y=o("br",null,null,-1),Q=o("div",null,[o("b",null,"\u8BF7\u6C42\u5934\uFF1A")],-1),W=o("br",null,null,-1),X=o("div",null,[o("b",null,"\u8BF7\u6C42\u53C2\u6570\uFF1A")],-1),Z=o("br",null,null,-1),ee=A("\u70B9\u51FB\u8BF7\u6C42"),te=o("br",null,null,-1),le=o("div",null,[o("b",null,"\u54CD\u5E94\u7ED3\u679C\uFF1A")],-1),ue=o("br",null,null,-1),re=S({__name:"api-test",setup(oe,{expose:E}){const v=m(!1),g=m(),e=O({ipPort:"",tokenUrl:"",path:"",url:"",type:"",contentType:"",apiToken:"",jsonParam:"",responseResult:""}),B=m({url:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],type:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],contentType:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),_=m(),f=m(),r=m(),R=l=>{v.value=!0,N().then(t=>{e.ipPort=t.data,e.path=l.path,e.url="http://"+t.data+l.path,e.tokenUrl="http://"+t.data+"token/generate?appKey=xxx&appSecret=xxx"}),e.type=l.type,e.contentType=l.contentType,h(l.jsonParam),F(),_.value=l.previlege},h=l=>{if(f.value){f.value.setEditorValue(l);return}setTimeout(()=>{h(l)},500)},F=()=>{if(r.value){r.value.setEditorValue("");return}setTimeout(()=>{F()},500)},y=J.create({timeout:6e5}),C=()=>{let l=f.value.getEditorValue();l=l?JSON.parse(l):{};const t={headers:{apiToken:e.apiToken}};if(e.type=="GET"){let u="",d=0;for(let i in l)d==0?u+="?"+i+"="+l[i]:u+="&"+i+"="+l[i],d++;y.get(e.url+u,t).then(i=>{r.value.setEditorValueAndFormat(JSON.stringify(i.data))}).catch(i=>{r.value.setEditorValueAndFormat(JSON.stringify(i))})}else e.type=="POST"?y.post(e.url,l,t).then(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u.data))}).catch(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u))}):e.type=="PUT"?y.put(e.url,l,t).then(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u.data))}).catch(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u))}):e.type=="DELETE"&&(t.data=l,y.delete(e.url,t).then(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u.data))}).catch(u=>{r.value.setEditorValueAndFormat(JSON.stringify(u))}))},D=()=>{P(e.tokenUrl).then(l=>{e.apiToken=l.data})};return E({init:R}),(l,t)=>{const u=p("el-input"),d=p("el-form-item"),i=p("el-button"),U=p("el-form"),q=p("el-tab-pane"),w=p("el-tabs"),x=p("el-drawer");return c(),T(x,{modelValue:v.value,"onUpdate:modelValue":t[7]||(t[7]=a=>v.value=a),title:"API \u6D4B\u8BD5",size:"100%","destroy-on-close":!0},{default:s(()=>[o("div",null,[n(w,{"tab-position":"top"},{default:s(()=>[n(q,{label:"\u8BF7\u6C42\u6D4B\u8BD5"},{default:s(()=>[n(U,{ref_key:"apiTestFormRef",ref:g,rules:B.value,model:e},{default:s(()=>[_.value==1?(c(),V("div",j,I)):b("",!0),z,_.value==1?(c(),T(d,{key:1,prop:"tokenUrl","label-width":"auto"},{default:s(()=>[n(u,{modelValue:e.tokenUrl,"onUpdate:modelValue":t[0]||(t[0]=a=>e.tokenUrl=a)},null,8,["modelValue"])]),_:1})):b("",!0),_.value==1?(c(),V("div",G,[n(i,{type:"primary",onClick:t[1]||(t[1]=a=>D())},{default:s(()=>[H]),_:1}),K,L])):b("",!0),M,Y,n(d,{label:"Request Url",prop:"url","label-width":"auto"},{default:s(()=>[n(u,{modelValue:e.url,"onUpdate:modelValue":t[2]||(t[2]=a=>e.url=a)},null,8,["modelValue"])]),_:1}),n(d,{label:"Request Method",prop:"type","label-width":"auto"},{default:s(()=>[n(u,{disabled:"",modelValue:e.type,"onUpdate:modelValue":t[3]||(t[3]=a=>e.type=a)},null,8,["modelValue"])]),_:1}),Q,W,n(d,{label:"Content-Type",prop:"contentType","label-width":"auto"},{default:s(()=>[n(u,{disabled:"",modelValue:e.contentType,"onUpdate:modelValue":t[4]||(t[4]=a=>e.contentType=a)},null,8,["modelValue"])]),_:1}),_.value==1?(c(),T(d,{key:3,label:"apiToken",prop:"apiToken","label-width":"auto"},{default:s(()=>[n(u,{modelValue:e.apiToken,"onUpdate:modelValue":t[5]||(t[5]=a=>e.apiToken=a)},null,8,["modelValue"])]),_:1})):b("",!0),X,Z,n(d,{"label-width":"auto",prop:"jsonParam"},{default:s(()=>[n(k,{id:"requestTestParam",ref_key:"requestTestParamRef",ref:f,style:{height:"160px",width:"100%"}},null,512)]),_:1}),o("div",null,[n(i,{type:"primary",onClick:t[6]||(t[6]=a=>C())},{default:s(()=>[ee]),_:1})]),te,le,ue,n(d,{"label-width":"auto",prop:"responseResult"},{default:s(()=>[n(k,{id:"responseTestResult",value:"",ref_key:"responseTestResultRef",ref:r,style:{height:"500px",width:"100%"}},null,512)]),_:1})]),_:1},8,["rules","model"])]),_:1})]),_:1})])]),_:1},8,["modelValue"])}}});export{re as _};
