mockm
Version:
Analog interface server, painless parallel development of front and back ends.
1 lines • 55.9 kB
JavaScript
(this["webpackJsonpmockm-client"]=this["webpackJsonpmockm-client"]||[]).push([[0],{289:function(e,t,a){},311:function(e,t,a){},312:function(e,t,a){},351:function(e,t,a){},427:function(e,t,a){},428:function(e,t,a){},433:function(e,t,a){},434:function(e,t,a){},435:function(e,t,a){},454:function(e,t){},456:function(e,t,a){},457:function(e,t,a){},458:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a.n(n),s=a(45),c=a.n(s),i=(a(311),a.p,a(47)),r=(a(312),a(7));var l=a(67),d=a(36),p=a(305),h=a(296),u=a.n(h),m=a(284);a(351);const{message:b}=d,j={};j.IconFont=m.a({scriptUrl:"font/iconfont.js"}),j.cfg={baseURL:(window.location.origin+window.location.pathname).replace(/\/$/,"")},j.http=u.a.create({baseURL:j.cfg.baseURL,timeout:0,headers:{"X-Custom-Header":"foobar"}}),j.http.interceptors.request.use((e=>{const{url:t}=e,[,a=""]=window.location.hash.match(/#\/history,(\w+)/)||[],n=new URL(t).origin,o=new RegExp("(".concat(n,"\\/api\\/)(\\w+)"));let s=t;return t.match(o)&&(s=t.replace(o,"$1$2".concat(a?",".concat(a):""))),e.url=s,e})),j.http.interceptors.response.use((e=>{const{data:t,config:a}=e;return a._raw?Promise.resolve(e):Promise.resolve(t)}),(e=>{if(void 0===e.response)return Promise.reject(e);const t=e.response.data;return b.error(t.msg||String(e)),Promise.reject(e)}));var g=j;const{http:f,cfg:x}=g;function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;const a=Object.prototype.toString.call(e).match(/\s(.+)]/)[1].toLowerCase();return t?a===t.toLowerCase():a}function w(){let{method:e,url:t,uri:a,path:n={},query:o={},header:s={},body:c={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=y(o,"array")?o:Object.keys(o).map((e=>({enabled:!0,key:e,value:o[e]}))),r=y(s,"array")?s:Object.keys(s).map((e=>({enabled:!0,key:e,value:s[e]}))),l={method:e,queryParameters:JSON.stringify(i),body:JSON.stringify(c),headers:JSON.stringify(r),url:C(t||a,n)};return"".concat(x.baseURL,"/restc/index.html#!").concat(O(l,!1))}function O(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"brackets",a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?"?":"",n=[];-1===["indices","brackets","repeat","comma"].indexOf(t)&&(t="brackets");for(let o in e){let a=e[o];if(!(["",void 0,null].indexOf(a)>=0))if(a.constructor===Array)switch(t){case"indices":for(let t=0;t<a.length;t++)n.push(o+"["+t+"]="+a[t]);break;case"brackets":default:a.forEach((e=>{n.push(o+"[]="+e)}));break;case"repeat":a.forEach((e=>{n.push(o+"="+e)}));break;case"comma":let e="";a.forEach((t=>{e+=(e?",":"")+t})),n.push(o+"="+e)}else n.push(o+"="+a)}return n.length?a+n.join("&"):""}function v(e){if("[object Array]"===Object.prototype.toString.call(e)){const t=[];for(let a=0;a<e.length;a++)t.push(v(e[a]));return t}if("[object Object]"===Object.prototype.toString.call(e)){const t={};for(let a in e)t[a]=e[a];return t}}function S(e){return[NaN,null,void 0,"",[],{}].some((t=>("string"!==typeof e||!e)&&JSON.stringify(e)===JSON.stringify(t)))}function k(e,t,a){if(void 0===t||""===t||0===t.length)return e;let n=(Array.isArray(t)?t:t.replace(/\[/g,".").replace(/\]/g,"").split(".")).reduce(((e,t)=>(e||{})[t]),e);return void 0!==n?n:a}function D(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return(t=Array.isArray(t)?t:t.replace(/\[/g,".").replace(/\]/g,"").split(".")).length>1?(e[t[0]]=e[t[0]]||{},D(e[t[0]],t.slice(1),a,n),e):(e[t[0]]=a,n&&void 0===a&&(Array.isArray(e)?e.splice(t[0],1):delete e[t[0]]),e)}function C(e,t){let a="";try{a=new URL(e).origin,e=e.replace(a,"")}catch(n){console.log("error",n)}return[...e.matchAll(/:(.+?)\b/g)].forEach((a=>{let[n,o]=a;e=e.replace(n,t[o])})),[...e.matchAll(/{+(.+?)}+/g)].forEach((a=>{let[n,o]=a;e=e.replace(n,t[o])})),a+e}var I={tryApi:async function(){var e;let{apiPath:t,method:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=await f.get("".concat(x.baseURL,"/api/studio/"),{params:{path:t}}),o=(null===n||void 0===n||null===(e=n[a])||void 0===e?void 0:e.parameters)||{};await Promise.all(Object.keys(o).map((e=>{const{table:t=[],example:{rule:a,type:n="object"}={}}=o[e];return new Promise(((s,c)=>{f.post("".concat(x.baseURL,"/api/listToData/"),{table:t,rule:a,type:n}).then((t=>{o[e].data=t,s(t)}))}))})));const{query:{data:s}={},"form/body":{data:c}={},header:{data:i}={},path:{data:r}={}}=o,l={method:a,query:s,body:c,path:r,header:i,url:"http://".concat(window.serverConfig.osIp,":").concat(window.serverConfig.port).concat(t)};window.open(w(l))},isIp4InPrivateNet:function(e){const t=e=>e.split(".").reverse().reduce(((e,t,a)=>e+parseInt(t,10)*Math.pow(256,a)),0),a=["10.0.0.0/10.255.255.255","172.16.0.0/172.31.255.255","192.168.0.0/192.168.255.255","169.254.0.0/169.254.255.255","127.0.0.0/127.255.255.255"].map((e=>e.split("/").map(t))),n=t(e);return!!a.find((e=>{let[t,a]=e;return t===(n&a)>>>0}))},setPathVal:C,isType:y,getRestcLink:w,toAbsURL:function(e){const t=document.createElement("a");return t.href=e,t.href},queryParams:O,onChange:function(e,t,a){let{state:n,setState:o}=a,s=e;"function"===typeof e.persist&&(e.persist(),s=e.target.value);const c=k(n,t);JSON.stringify(c)!==JSON.stringify(s)&&o((e=>({...D(e,t,s)})))},docLink:function(e,t){return Object(r.jsx)("a",{rel:"noopener noreferrer",target:"_blank",href:"https://wll8.github.io/mockm".concat(t),children:e})},deepCopy:v,tree2Array:function(e,t){const a=[],n=[];a.push(e);let o=t;const s=v(e);for(s.pid=o,delete s.children,n.push(s);a.length>0;){const e=a.shift(),t=e.children;if(t&&t.length>0){o=e.id;const s=e.children.length;for(let e=0;e<s;e++){a.push(t[e]);const s=v(t[e]);s.pid=o,delete s.children,n.push(s)}}}return n},objOrLine:function(e){let t;if("string"===typeof e){t=e.replace(/[\r\n]/g,"\n").split(/\n/).reduce(((e,t)=>{let[,a="",n=""]=t.match(/(.*):(.*)/)||[];return a=a.trim(),n=n.trim(),{...e,...a?{[a]:n}:{}}}),{})}else if("object"===typeof e){const a=e;t=Object.keys(a).reduce(((e,t)=>"".concat(e,"\n").concat(t,": ").concat(a[t])),"").trim()}return t},showTitle:function(e,t){return t?Object(r.jsx)("span",{title:t,children:e}):e},search:function e(t,a,n){for(const o in t){if(o===a&&t[o]===n)return[o];if("object"===typeof t[o]){const s=e(t[o],a,n);if(s)return[o,s].flat()}}},setListVal:function e(t){let{arr:a,key:n,val:o,childrenKey:s,cover:c=!1}=t;return a.forEach((t=>{t[n]=void 0===t[n]||!0===c?"function"===typeof o?o():o:t[n],Array.isArray(t[s])&&e({arr:t[s],key:n,val:o,childrenKey:s})})),a},guid:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").replace(/[x]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},removeKeys:function(e,t){return JSON.parse(JSON.stringify(e,((e,a)=>t.includes(e)?void 0:a)))},removeEmpty:function(e){return JSON.parse(JSON.stringify(e),((e,t)=>(!1===S(t)&&Array.isArray(t)&&(t=t.filter((e=>!S(e)))),S(t)?void 0:t)))},swgPathToReg:function(e){return new RegExp(e.replace(/\{.+?\}/g,".+?")+"$")},getAbsolutePosition:function(e){if(!e)return null;var t,a,n=e.offsetWidth,o=e.offsetHeight;for(t=e.offsetTop,a=e.offsetLeft;e=e.offsetParent;)t+=e.offsetTop,a+=e.offsetLeft;return{width:n,height:o,top:t,left:a,right:document.body.offsetWidth-n-a,bottom:document.body.offsetHeight-o-t}},debounce:function(e,t){var a=null;return function(){null!==a&&clearTimeout(a),a=setTimeout(e,t)}},dateDiff:function(e,t){var a=(t||(new Date).getTime())-e,n=36e5,o=24*n,s=30*o,c=a/(12*s),i=a/s,r=a/(7*o),l=a/o,d=a/n,p=a/6e4;return c>=1?parseInt(c)+"\u5e74\u524d":i>=1?parseInt(i)+"\u4e2a\u6708\u524d":r>=1?parseInt(r)+"\u5468\u524d":l>=1?parseInt(l)+"\u5929\u524d":d>=1?parseInt(d)+"\u5c0f\u65f6\u524d":p>=1?parseInt(p)+"\u5206\u949f\u524d":"\u521a\u521a"},getSelectionText:function(){var e="";return window.getSelection?e=window.getSelection().toString():document.selection&&"Control"!==document.selection.type&&(e=document.selection.createRange().text),e},blobTool:async function(e,t,a){return new Promise(((n,o)=>{if("download"===t){var s=document.createElement("a"),c=window.URL.createObjectURL(e);s.href=c,s.download=a,s.click(),window.URL.revokeObjectURL(c),n(c)}if("toBase64"===t){let t=new FileReader;t.readAsDataURL(e),t.onload=e=>{const t=e.target.result;n(t)}}if("toObjectURL"===t){const t=window.URL.createObjectURL(e);n(t)}if("toText"===t){let t=new FileReader;t.readAsText(e,"utf-8"),t.onload=e=>{const t=e.target.result;n(t)}}}))},getMethodUrl:function(e){const[,t,a]=e.match(/(\w+)\s+(.*)/);return{method:t,api:a}},fetchDownload:function(e,t){fetch(e).then((e=>e.blob())).then((a=>{var n=document.createElement("a"),o=window.URL.createObjectURL(a),s=t||e.replace(/.*\//,"");n.href=o,n.download=s,n.click(),window.URL.revokeObjectURL(o)}))},copyToClipboard:function(e){var t=document.createElement("textarea");t.style.position="fixed",t.style.zIndex="-9",t.style.top="-100%",t.style.left="-100%",t.value=e,document.body.appendChild(t),t.select();var a=!1;try{a=document.execCommand("copy")}catch(n){console.log("\u8be5\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u70b9\u51fb\u590d\u5236\u5230\u526a\u8d34\u677f")}return document.body.removeChild(t),a},wordToUpperCase:function(e){return e.replace(/(\w+)/g,(e=>e.charAt().toUpperCase()+e.slice(1)))},sortKey:function(e){const t={};return Object.keys(e).sort().forEach((a=>t[a]=e[a])),t},deepGet:k,deepSet:D};a(427);window.$,window.HotKey;const{http:R,cfg:T}=g,{getSelectionText:N,getMethodUrl:L,wordToUpperCase:P,sortKey:A,formatData:U,deepGet:H,deepSet:B,dateDiff:q}=I,E=(()=>{const{useState:e,useEffect:t,useRef:a}=o.a,{Table:n,Collapse:s,Button:c,Tag:i,Tabs:l,BackTop:p,message:h,Spin:u}=d,{Panel:m}=s,{TabPane:b}=l;return function(a){const[o,s]=e({loading:!1,defaultPageSize:100,defaultPageIndex:1,defaultSort:"date",defaultOrder:"desc",apiListData:{count:0,results:[]}}),c=[{title:"api",sorter:!0,ellipsis:!0,render:e=>Object(r.jsx)("a",{href:"#/history,".concat(e.id,"/").concat(e.method).concat(e.api),children:e.api})},{title:"id",width:80,dataIndex:"id",sorter:!0},{title:"code",width:100,dataIndex:"statusCode",sorter:!0},{title:"type",width:100,dataIndex:"extensionName",sorter:!0},{title:"method",width:120,dataIndex:"method",sorter:!0},{title:"date",width:100,dataIndex:"date",sorter:!0,defaultSortOrder:"descend",render:e=>q(new Date(e))}];function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{_sort:o.defaultSort,_order:o.defaultOrder,_page:o.defaultPageIndex,_limit:o.defaultPageSize};s((e=>({...e,loading:!0}))),R.get("".concat(T.baseURL,"/api/getApiList/"),{params:e}).then((e=>{e.results=e.results.map(((e,t)=>({...e,key:t}))),s((t=>({...B(t,"apiListData",e)})))})).finally((()=>{s((e=>({...e,loading:!1})))}))}return t((()=>{i()}),[]),Object(r.jsx)("div",{className:"ApiList",children:Object(r.jsx)(n,{scroll:{x:800},loading:o.loading,size:"small",rowKey:"key",pagination:{defaultPageSize:o.defaultPageSize,total:o.apiListData.count,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>"Total ".concat(e," items")},columns:c,dataSource:o.apiListData.results,onChange:function(e,t,a,n){console.log("params",e,t,a,n),i({_sort:a.field,_order:{ascend:"asc",descend:"desc"}[a.order||"ascend"],_page:e.current,_limit:e.pageSize})}})})}})();var J=E;a(301),a(428);window.$,window.HotKey;const{http:z,cfg:M}=g,{copyToClipboard:_,wordToUpperCase:K,sortKey:F,formatData:$,deepGet:V,deepSet:W,blobTool:G}=I;var X=(()=>{const{useState:e,useEffect:t,useRef:a}=o.a,{Collapse:n,Button:s,Tag:c,message:i}=d;return function(a){const n={activePanel:["req","res"],activePanelPanel:{req:["lineHeaders","body"],res:["lineHeaders","body"]}},o=JSON.parse(window.localStorage.getItem("ReqResState"))||{activePanel:["req","res"],activePanelPanel:{req:["lineHeaders","body"],res:["lineHeaders","body"]}},[s,c]=e({...o,newHttpData:void 0});console.log("initState",o);const i=s.newHttpData;function l(e,t){V(t,"newHttpData.data.".concat(e,".bodyPath"))&&z.get("".concat(M.baseURL,"/api/getBodyFile").concat(d(e),"/").concat(t.newHttpData.method).concat(t.newHttpData.api),{responseType:"blob"}).then((a=>{const n=a;Promise.all([G(n,"toText"),G(n,"toBase64"),G(n,"toObjectURL")]).then((a=>{let[o,s,i]=a;if("application/json"===n.type)try{o=JSON.stringify(JSON.parse(o),null,2)}catch(l){console.log(l),o=l}const r={...V(t,"newHttpData.data.".concat(e),{}),bodyBlob:n,bodyText:o,bodyBase64:s,bodyObjectURL:i};c((a=>({...W(t,"newHttpData.data.".concat(e),r)})))}))}))}function d(e){return e.replace(/(.)(.*)/,((e,t,a)=>t.toLocaleUpperCase()+a))}function p(e){let{panel:t,panelPanel:a}=e;const n=e=>{let t={};t="string"===typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)};function o(e){let{type:t,chidren:a}=e;return Object(r.jsx)("div",{className:"preview ".concat(t),children:a})}if("lineHeaders"===a){const e=V(s,"newHttpData.data.".concat(t,".lineHeaders"));return o({type:"application/json",chidren:n(e)})}const c="newHttpData.data.".concat(t,".lineHeaders.headers.content-type"),{bodyBlob:l,bodyBase64:p,bodyText:h,bodyObjectURL:u}=V(s,"newHttpData.data.".concat(t)),m=V(s,c,"").split(";")[0],b=m.replace(/\/.*/,""),j="".concat(M.baseURL,"/api/getBodyFile").concat(d(t),",").concat(i.apiId,"/").concat(i.method).concat(i.api),g=e=>Object(r.jsxs)("div",{className:"noPre",children:[Object(r.jsx)("div",{className:"msg",children:"\u6b64\u6587\u4ef6\u7c7b\u578b\u6682\u4e0d\u652f\u6301\u9884\u89c8:"}),Object(r.jsx)("div",{className:"type",children:m}),Object(r.jsx)("div",{className:"msg",children:"\u94fe\u63a5:"}),Object(r.jsx)("div",{className:"linkBox",children:Object(r.jsx)("a",{className:"link",rel:"noopener noreferrer",target:"_blank",href:j,children:j})})]}),f=e=>Object(r.jsxs)("div",{className:"ComHeightText",children:["\u989c\u8272\u9ad8\u4eae: ",h]});return o({type:m,chidren:({"text/html":()=>Object(r.jsx)("iframe",{title:u,className:"htmlViewIframe",src:u}),"application/json":()=>n(h)}[m]||{application:()=>["application/javascript","application/xml"].includes(m)?f():g(),audio:()=>Object(r.jsx)("audio",{controls:!0,children:Object(r.jsx)("source",{src:j,type:m})}),chemical:g,image:()=>Object(r.jsx)("img",{src:j,alt:j}),message:g,model:g,text:f,video:()=>Object(r.jsx)("video",{controls:!0,children:Object(r.jsx)("source",{src:j,type:m})}),"x-conference":g,font:g,undefined:g,"":g}[b])()})}return console.log("httpData",i),console.log("newHttpData",s.newHttpData),t((()=>{c((e=>({...W(s,"newHttpData",a.httpData)}))),l("req",{...s,newHttpData:a.httpData}),l("res",{...s,newHttpData:a.httpData})}),[a.httpData]),Object(r.jsx)("div",{className:"ReqRes",children:function(t){const[a,o]=e(JSON.parse(JSON.stringify(t)));function s(e,n){const s=V(a,n),c=s.some((t=>t===e))?function(e,t){var a=(e=[...e]).indexOf(t);return a>-1&&e.splice(a,1),e}(s,e):[...s,e];o((e=>{const a={...W(e,n,c)};return t.cb(a),a}))}return Object(r.jsx)("div",{className:"detailsBox",children:n.activePanel.map((e=>Object(r.jsxs)("details",{disabled:!0,open:t.activePanel.includes(e),children:[Object(r.jsx)("summary",{onClick:t=>s(e,"activePanel"),children:e}),Object(r.jsx)("div",{children:n.activePanelPanel[e].filter((t=>"body"!==t||"body"===t&&void 0!==V(i,"data.".concat(e,".bodyPath")))).map((a=>Object(r.jsxs)("details",{open:t.activePanelPanel[e].includes(a),children:[Object(r.jsx)("summary",{onClick:t=>s(a,"activePanelPanel.".concat(e)),children:a}),Object(r.jsx)("div",{className:"content",children:p({panel:e,panelPanel:a})})]},a)))})]},e)))})}({activePanel:s.activePanel,activePanelPanel:s.activePanelPanel,cb:e=>{console.log("collapseChange",e),window.localStorage.setItem("ReqResState",JSON.stringify(e,null,2))}})})}})(),Q=a(302),Y=a.n(Q);const{blobTool:Z}=I,{useState:ee,useEffect:te}=o.a,{Button:ae}=d;var ne=function(e){const[t,a]=ee({captureImg:e.captureImg});return te((()=>{a((t=>({...t,captureImg:e.captureImg})))}),[e.captureImg]),Object(r.jsx)(ae,{onClick:function(){if(t.captureImg)a((e=>({...e,captureImg:void 0}))),e.cb(void 0);else{const t=document.querySelector(".ApiDetail"),n=1.5,o={height:t.offsetHeight*n,width:t.offsetWidth*n,style:{transform:"scale("+n+")",transformOrigin:"top left",width:t.offsetWidth+"px",height:t.offsetHeight+"px"}};Y.a.toBlob(t,o).then((async function(t){const n=await Z(t,"toObjectURL");return a((e=>({...e,captureImg:n}))),e.cb(n),n})).catch((e=>{console.log("err",e)}))}},size:"small",type:t.captureImg?"primary":"default",className:"capture",children:"capture"})},oe=a(51);const{http:se,cfg:ce}=g,{useState:ie}=o.a,{message:re,Button:le}=d;var de=function(e){let{method:t,api:a}=e;const[n,o]=ie({replayDone:!0});return Object(r.jsxs)(le,{onClick:function(){o((e=>({...e,replayDone:!1}))),se.get("".concat(ce.baseURL,"/api/replay/").concat(t).concat(a)).then((e=>{o((e=>({...e,replayDone:!0}))),re.info("\u91cd\u53d1\u8bf7\u6c42\u6210\u529f ".concat(e.msg))}))},size:"small",className:"replay",children:["replay ",Object(r.jsx)(oe.a,{style:{display:n.replayDone?"none":void 0}})," "]})};const pe=window.$,{isIp4InPrivateNet:he,swgPathToReg:ue,getAbsolutePosition:me,debounce:be,deepSet:je}=I,{useState:ge,useEffect:fe}=o.a,{useLocation:xe}=l,{http:ye,cfg:we}=g,{message:Oe,Button:ve}=d;var Se=function(e){const t=xe(),[a,n]=ge({spec:{},specPrefix:"",swagger:!1,pathInSwagger:!1,swaggerLoading:!1});function o(e){let{store:a,cb:o}=e;pe("head").append(pe('<link rel="stylesheet" href="./cdn/npm/swagger-ui-dist@3.52.5/swagger-ui.css">')),pe("head").append(pe('<link rel="stylesheet" href="./swagger-reset.css">'));const s=e=>({rootInjects:{getSpec:()=>e.getState().toJSON().spec.json,getSpecPrefix:()=>e.getState().toJSON().spec.json.info._openApiPrefix||"",setSpec(t){const a=e.getState().toJSON().spec.json,o=e.getState().toJSON().spec.json.info._openApiPrefix||"",s={...a,...t};return n((e=>({...je(e,"spec",s)}))),n((e=>({...je(e,"specPrefix",o)}))),e.specActions.updateJsonSpec(s)}}});pe.getScript2("./cdn/npm/swagger-ui-dist@3.52.5/swagger-ui-bundle.min.js",(()=>{const e=function(){let e={};if(t.pathname.match(/^\/(\w+),(.*)/)){let[,a,n]=t.pathname.match(/\/(.*?)(\/.*)/);const[o,...s]=a.split(","),c=s.join(",");e={...e,action:o,actionArg:s,actionArgStr:c};const[,i,r]="#".concat(n).concat(t.search).match(/#\/(\w+)(.*)/)||[];e={...e,method:i,api:r}}else{const[,a,n]="#".concat(t.pathname).concat(t.search).match(/#\/(\w+)(.*)/)||[];e={...e,method:a,api:n}}return e}();window.swaggerUi=window.SwaggerUIBundle({url:"".concat(we.baseURL,"/api/getOpenApi/").concat(e.api?"?api=".concat(e.api):""),dom_id:"#swagger-ui",plugins:[s],requestInterceptor:e=>new Promise(((t,a)=>{ye.get("".concat(we.baseURL,"/api/getInjectionRequest/")).then((t=>{Object.entries(t).forEach((t=>{let[a,n]=t;void 0!==n&&je({req:e},a,n)}))})).finally((()=>{setTimeout((()=>t(e)),0)}))})),configs:{preFetch:e=>e},onComplete(){const e=window.swaggerUi.getSpec(),t=window.swaggerUi.getSpecPrefix(),n=window.location.hostname;let s="";s="localhost"===n||n.split("").every((e=>e.match(/[0-9]|\./)))&&!1===he(n)?"".concat(n,":").concat(window.serverConfig.port):new URL(a.note.remote.port||a.note.local.port).host;const c=(e.servers||[]).map((e=>{const a=e.url.replace(new URL(e.url).host,s);return e.url="".concat(a).concat(t),e})),i=window.location.protocol.replace(":","");window.swaggerUi.setSpec({servers:c,host:s,protocol:i,schemes:[i]}),o()}})}),!0)}function s(){n((e=>({...e,swagger:!1}))),pe(".swaggerBox").addClass("hide").removeClass("show"),pe("#root").css({width:""})}return fe((()=>{try{let{headers:{authorization:t},line:{method:o,path:s}}=e.httpData.data.req.lineHeaders,{paths:c=[],basePath:i=""}=a.spec;o=o.toLowerCase();const r=new RegExp("^(".concat(i,")(/.*)")),l=s.replace(r,"$2"),d=Object.keys(c).some((e=>{e="".concat(a.specPrefix).concat(e);let t=ue(e);return l.match(t)}));n((e=>({...je(e,"pathInSwagger",d)}))),n((e=>({...je(e,"authorization",t)})))}catch(t){console.log("error",t),n((e=>({...je(e,"pathInSwagger",!1)})))}}),[a.spec,a.specPrefix,e]),fe((()=>s),[]),fe((()=>{Promise.all([ye.get("".concat(we.baseURL,"/api/getStore/"))]).then((e=>{let[t]=e;window.serverConfig.openApi&&(n((e=>({...je(e,"swaggerLoading",!0)}))),o({store:t,cb:()=>{n((e=>({...je(e,"swaggerLoading",!1)})))}}))}))}),[t]),Object(r.jsx)(ve,{loading:a.swaggerLoading,onClick:function(){if(pe(".swaggerBox").hasClass("show"))s();else{let{line:{method:t,path:o}}=e.httpData.data.req.lineHeaders;t=t.toLowerCase();const c=a.spec.basePath,i=new RegExp("^(".concat(c,")(/.*)")),r=o.replace(i,"$2"),l=pe([...pe(".opblock-summary-".concat(t," [data-path]"))].find((e=>{let t=ue(pe(e).data("path"));return r.match(t)})));if(0===l.length)return Oe.error("\u672a\u627e\u5230\u6587\u6863"),!1;const d=l.parents(".opblock");!1===d.hasClass("open")&&l.click(),d.addClass("open");const p="DOMAttrModified DOMAttributeNameChanged DOMCharacterDataModified DOMElementNameChanged DOMNodeInserted DOMNodeInsertedIntoDocument DOMNodeRemoved DOMNodeRemovedFromDocument DOMSubtreeModified";function h(){const e=me(d[0]);if(0===e.height)return!1;{let t="".concat(e.height,"px");pe("#swagger-ui").css({height:t})}}pe(".opblock").off(p),setTimeout(h,500),d.on(p,be(h,100)),function(e){let{$swaggerApiDom:t}=e;n((e=>({...e,swagger:!0}))),pe(".swaggerBox").removeClass("hide").addClass("show"),pe("#root").css({width:"50%"}),pe("#swagger-ui").scrollTo(t.parent())}({$swaggerApiDom:l})}},size:"small",type:a.swagger?"primary":"default",className:"swagger",disabled:!a.pathInSwagger,children:"swagger"})},ke=a(89);const{http:De,cfg:Ce}=g,{showTitle:Ie,docLink:Re}=I,{useState:Te}=o.a,{message:Ne,Button:Le,Popconfirm:Pe,Dropdown:Ae,Menu:Ue}=d,{DownOutlined:He,UserOutlined:Be}=ke;var qe=function(e){let{httpData:t,simpleInfo:a}=e;const[n,o]=Te({replayDone:!0}),s=new URL("http://127.0.0.1".concat(t.api)).pathname,{useHistory:c,useLocation:i}=l;function d(){o((e=>({...e,replayDone:!1})));const e=t.method,n=(t.apiId,t.data.res.bodyText),c=t.data.res.lineHeaders.headers,i=a.extensionName;if("json"!==i)return Ne.error("\u6682\u4e0d\u652f\u6301 ".concat(i," \u683c\u5f0f\u7684\u6570\u636e")),!1;const r=["(req, res) => {","res.set(".concat(JSON.stringify(Object.entries(c).reduce(((e,t)=>{let[a,n]=t;return a.match(/^access-control-allow-/i)||a.match(new RegExp("^".concat(window.serverConfig.apiInHeader)))||(e[a]=n),e}),{}),null,2),")"),"res.json(".concat(n,")"),"}"].join("\n");console.log(r),De.patch("".concat(Ce.baseURL,"/api/studio/"),{setPath:["paths",s,e,"responses",200,"example"],data:{useDataType:"custom",custom:r}}).then((e=>{Ne.info("\u8bbe\u7f6e\u6210\u529f"),setTimeout((()=>{window.location.reload()}),500)}))}function p(){o((e=>({...e,replayDone:!1})));const e=t.method,a=t.apiId;De.patch("".concat(Ce.baseURL,"/api/studio/"),{setPath:["paths",s,e,"responses",200,"example"],data:{useDataType:"history",history:a}}).then((e=>{Ne.info("\u8bbe\u7f6e\u6210\u529f"),setTimeout((()=>{window.location.reload()}),500)}))}c();const h=Object(r.jsxs)(Ue,{onClick:function(e){(0,{historyData:d,historyId:p,switch(){De.post("".concat(Ce.baseURL,"/api/changeWebApiStatus/"),{api:"".concat(t.method," ").concat(t.api)}).then((e=>{Ne.info("\u64cd\u4f5c\u6210\u529f"),setTimeout((()=>{window.location.reload()}),500)}))},detail(){window.open("#/apiStudio/edit?path=".concat(s,"&method=").concat(t.method))}}[e.key])()},children:[Object(r.jsxs)(Ue.SubMenu,{title:Ie("\u4f7f\u7528\u6b64\u8bb0\u5f55","\u603b\u662f\u4ee5\u8fd9\u6761\u8bb0\u5f55\u7684\u54cd\u5e94\u4f5c\u4e3a\u6b64\u63a5\u53e3\u7684\u8fd4\u56de\u503c, \u8fd9\u5c06\u81ea\u52a8\u521b\u5efa\u6216\u4fee\u6539\u63a5\u53e3"),children:[Object(r.jsx)(Ue.Item,{children:Ie("\u4f7f\u7528\u6570\u636e","\u590d\u5236\u6b64\u8bb0\u5f55\u7684\u54cd\u5e94\u6570\u636e\u6765\u521b\u5efa\u63a5\u53e3")},"historyData"),Object(r.jsx)(Ue.Item,{children:Ie("\u4f7f\u7528ID","\u4ec5\u4f7f\u7528ID\u6765\u54cd\u5e94 httpData/request \u76ee\u5f55\u4e2d\u5bf9\u5e94\u7684\u6570\u636e")},"historyId")]},"history"),Object(r.jsx)(Ue.Item,{disabled:!t.webApi,children:(t.webApi||{}).disable?"\u542f\u7528":"\u7981\u7528"},"switch"),Object(r.jsx)(Ue.Item,{disabled:!t.webApi,children:"\u7f16\u8f91"},"detail")]});return Object(r.jsx)(Ae,{overlay:h,children:Object(r.jsxs)(Le,{size:"small",children:["webApi ",Object(r.jsx)(He,{})]})})};const{http:Ee,cfg:Je}=g,{dateDiff:ze,deepSet:Me}=I,{useHistory:_e,useLocation:Ke}=l,{Drawer:Fe,Button:$e,Table:Ve}=d,{useState:We}=o.a;var Ge=function(e){const t=_e(),a=Ke(),[n,o]=We({captureImg:void 0}),s=[{title:"id",dataIndex:"id"},{title:"date",dataIndex:"date",sorter:(e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime(),defaultSortOrder:"descend",render:e=>ze(new Date(e))},{title:"code",dataIndex:"statusCode",sorter:(e,t)=>e.statusCode-t.statusCode},{title:"res",dataIndex:"resBodySize",sorter:(e,t)=>t.resBodySize-e.resBodySize},{title:"req",dataIndex:"reqBodySize",sorter:(e,t)=>t.reqBodySize-e.reqBodySize}];function c(t){o((e=>({...Me(e,"showHistry",t)}))),t&&Ee.get("".concat(Je.baseURL,"/api/getApiHistry/").concat(e.api0)).then((e=>{console.log("resres",e),e=e.map(((e,t)=>({...e,key:t}))),o((t=>({...Me(t,"dataApiHistry",e)})))}))}return Object(r.jsxs)(r.Fragment,{children:[Object(r.jsx)($e,{onClick:()=>c(!0),size:"small",className:"history",children:"history"}),Object(r.jsx)(Fe,{className:"drawer",title:"history",width:"none",onClose:()=>c(!1),visible:n.showHistry,children:Object(r.jsx)(Ve,{onRow:e=>({onClick:a=>{t.push("/history,".concat(e.id,"/").concat(e.method).concat(e.api))}}),rowClassName:(t,n)=>{const o=a.pathname.match(/\/history,(\w+)/);return t.id===e.apiId||null===o&&0===n?"curItem index_".concat(n):"index_".concat(n)},showHeader:!0,rowKey:"key",size:"small",pagination:!1,columns:s,dataSource:n.dataApiHistry})})]})};a(433);const{http:Xe,cfg:Qe}=g,Ye=(window.$,window.HotKey),{getSelectionText:Ze,deepGet:et,deepSet:tt}=I;var at=(()=>{const{useState:e,useEffect:t,useRef:a}=o.a,{Collapse:n,Button:s,Tabs:c,message:i,Spin:p,Table:h}=d,{Panel:u}=n,{TabPane:m}=c;return function(){const{useHistory:a,useLocation:n}=l,o=(()=>{try{return JSON.parse(window.localStorage.getItem("ApiDetailState"))||{}}catch(e){console.log(e)}return{activeTabs:"ReqRes"}})(),[s,i]=e({...o,httpData:{},showHistry:!1,dataApiHistry:[],parseHashData:{},captureImg:void 0}),d=n();function p(e){if(!e.data)return{};const t=e.data.res,{method:a,api:n}=e;return{method:a,api:n,statusCode:t.lineHeaders.line.statusCode,contentType:t.lineHeaders.headers["content-type"],extensionName:(t.bodyPath||"").replace(/(.*)(\.)/,""),date:t.lineHeaders.headers.date}}t((()=>{window.localStorage.setItem("ApiDetailState",JSON.stringify({activeTabs:s.activeTabs},null,2))}),[s.activeTabs]),t((()=>{console.log("location",d),console.log("location.pathname",d.pathname);const e=function(){let e={};if(d.pathname.match(/^\/(\w+),(.*)/)){let[,t,a]=d.pathname.match(/\/(.*?)(\/.*)/);const[n,...o]=t.split(","),s=o.join(",");e={...e,action:n,actionArg:o,actionArgStr:s};const[,c,i]="#".concat(a).concat(d.search).match(/#\/(\w+)(.*)/)||[];e={...e,method:c,api:i}}else{const[,t,a]="#".concat(d.pathname).concat(d.search).match(/#\/(\w+)(.*)/)||[];e={...e,method:t,api:a}}return e}(),{api:t,method:a,action:n,actionArg:o}=e;a&&t&&function(e){let{method:t,api:a,parseHashData:n}=e;console.log("method, api",t,a);const o=window.decodeURIComponent("".concat(t," ").concat(a));console.log("fullApi",o,s.parseHashData),Xe.get("".concat(Qe.baseURL,"/api/getHttpData/").concat(t).concat(a)).then((e=>{let{webApi:s,historyRes:{data:c}}=e;const[,r]=window.location.hash.match(/#\/history,(\w+)/)||[],l={webApi:s,method:t,api:a,api0:"".concat(t).concat(a),apiId:r,data:c};i((e=>({...e,parseHashData:n,captureImg:void 0,fullApi:o,httpData:l,simpleInfo:p(l)})))}))}({method:a,api:t,parseHashData:e});const c=new Ye;return c.add("CTRL+C",(e=>{Ze()||console.log("ctrl+c")})),c.setup({metaToCtrl:!0}),c.start(),()=>c.stop()}),[d]);const h={ReqRes:X};return s.httpData.data?Object(r.jsxs)("div",{className:"ApiDetail",children:[Object(r.jsxs)("div",{className:"info",children:[Object(r.jsxs)("div",{className:"item api",children:[Object(r.jsx)("span",{className:"key",children:"api:"}),Object(r.jsx)("span",{className:"val",children:s.fullApi})]}),Object(r.jsxs)("div",{className:"item status",children:[Object(r.jsx)("span",{className:"key",children:"status:"}),Object(r.jsxs)("span",{className:"val",children:[et(s,"httpData.data.res.lineHeaders.line.statusCode")," ",et(s,"httpData.data.res.lineHeaders.line.statusMessage")]})]})]}),Object(r.jsxs)("div",{className:"options",children:[Object(r.jsx)(de,{method:s.httpData.method,api:s.httpData.api}),Object(r.jsx)(ne,{cb:function(e){i((t=>({...t,captureImg:e})))},captureImg:s.captureImg}),Object(r.jsx)(Se,{httpData:s.httpData}),Object(r.jsx)(Ge,{apiId:s.httpData.apiId,api0:s.httpData.api0}),Object(r.jsx)(qe,{simpleInfo:s.simpleInfo,httpData:s.httpData}),Object(r.jsx)("div",{className:"optionsPreViewRes ".concat(s.captureImg&&"show"),children:s.captureImg&&Object(r.jsx)("img",{className:"captureImg",src:s.captureImg,alt:"captureImg"})})]}),Object(r.jsx)(c,{animated:!1,defaultActiveKey:s.activeTabs,onChange:function(e){console.log(e),i((t=>({...tt(t,"activeTabs",e)})))},children:Object.keys(h).map((e=>Object(r.jsx)(m,{tab:e,children:s.httpData?(()=>{const t=h[e];return Object(r.jsx)(t,{httpData:s.httpData})})():"(\u6682\u65e0)"},e)))})]}):""}})();const{getRestcLink:nt,tree2Array:ot}=I,{BackTop:st,ConfigProvider:ct,Breadcrumb:it,Menu:rt}=d;function lt(e){const t={id:"^/index/?$",name:"\u9996\u9875",path:"/",children:[{id:"^/?$",name:"\u8bb0\u5f55",path:"/",children:[{id:"^/history,.*",name:"\u8be6\u60c5",path:"/history/"},{id:"get|post|put|patch|delete|head|options|trace".split("|").map((e=>"(^/".concat(e,"/.*)"))).join("|"),name:"\u8be6\u60c5",path:"/history/"}]},{id:"^/restc/?$",name:"\u8bf7\u6c42",path:"/restc/"},{id:"^/apiStudio/?$",name:"\u63a5\u53e3",path:"/apiStudio/",children:[{id:"^/apiStudio/edit/?$",name:"\u8be6\u60c5",path:"/apiStudio/edit/"}]}]},a=ot(t),{id:n}=a.find((t=>e.match(new RegExp(t.id)))),o=a.reduce(((e,t)=>{const n=a.find((t=>t.id===e.findPid));return n?{findPid:n.pid,res:e.res.concat(n)}:e}),{findPid:n,res:[]}).res;return console.log("newList",{newList:a,resList:o,id:n}),o.reverse()}var dt=function(){const{useState:e,useEffect:t}=o.a,[a,n]=e({routePath:""}),{useLocation:s}=l,c=s();return t((()=>{console.log("useEffect");const e=c.pathname;n((t=>({...t,routePath:e})))}),[c]),Object(r.jsx)("div",{className:"Breadcrumb",children:Object(r.jsx)(it,{children:a.routePath&<(a.routePath).map(((e,t,a)=>"\u9996\u9875"===e.name?Object(r.jsx)(it.Item,{overlay:Object(r.jsxs)(rt,{children:[Object(r.jsx)(rt.Item,{children:Object(r.jsx)("a",{href:"./#/",children:"\u8bb0\u5f55"})},"\u8bb0\u5f55"),Object(r.jsx)(rt.Item,{children:Object(r.jsx)("a",{href:"./#/apiStudio",children:"\u63a5\u53e3"})},"\u63a5\u53e3"),Object(r.jsxs)(rt.SubMenu,{title:"\u5de5\u5177",children:[Object(r.jsx)(rt.Item,{onClick:()=>{window.open(nt({method:"GET",header:[{enabled:!1,key:"X-Powered-By",value:"mockm"},{enabled:!0,key:"Authorization",value:"test"}],query:{_sort:"id",_order:"desc",_page:1,_limit:10},url:"http://".concat(window.serverConfig.osIp,":").concat(window.serverConfig.testPort,"/api/getApiList/")}))},children:"\u8bf7\u6c42"},"\u8bf7\u6c42"),Object(r.jsx)(rt.Item,{children:Object(r.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://wll8.github.io/mockm/?from=mockm",children:"\u6587\u6863"})},"\u6587\u6863"),Object(r.jsx)(rt.Item,{children:Object(r.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://wll8.github.io/mockjs-examples/?from=mockm",children:"mockjs"})},"mockjs")]},"\u5de5\u5177"),Object(r.jsx)(rt.Item,{children:Object(r.jsx)("a",{target:"_blank",rel:"noreferrer",href:"https://github.com/wll8/mockm?from=mockm",children:"github"})},"github")]}),children:"mockm"},t):Object(r.jsx)(it.Item,{children:t<a.length-1?Object(r.jsx)("a",{href:"./#".concat(e.path),children:e.name}):e.name},t)))})})};a(434);var pt=function(){return Object(r.jsx)("div",{className:"RestcCom",children:Object(r.jsx)("iframe",{title:"restc",className:"iframeRef",src:"./restc/index.html"})})},ht=(a(435),a(304)),ut=a(183),mt=a(293),bt=a(294);window.$,window.HotKey;const{http:jt,cfg:gt}=g,{tryApi:ft,getSelectionText:xt,getMethodUrl:yt,wordToUpperCase:wt,sortKey:Ot,formatData:vt,deepGet:St,deepSet:kt,dateDiff:Dt}=I,Ct=(()=>{const{useState:e,useEffect:t,useRef:a}=o.a,{Table:n,Collapse:s,Button:c,Tag:i,Tabs:l,Popconfirm:p,BackTop:h,message:u,Spin:m,Switch:b,Divider:j}=d,{Panel:g}=s,{TabPane:f}=l;return function(a){const[o,s]=e({loading:!1,apiListData:{results:[],disable:[]}}),c=[{title:"path",ellipsis:!0,width:200,render:e=>{const t=ht.stringify({path:e.path,method:e.method},{encode:!1});return"apiWeb"===e.type?Object(r.jsx)("a",{href:"#/apiStudio/edit?".concat(t),children:e.path}):e.path}},{title:"method",width:60,dataIndex:"method",render:e=>e||"--"},{title:"description",width:200,dataIndex:"description"},{title:"type",width:80,dataIndex:"type"},{title:e=>Object(r.jsxs)("div",{className:"title operation",children:[Object(r.jsx)(ut.a,{onClick:()=>window.location.href="#/apiStudio/edit"}),Object(r.jsx)(j,{type:"vertical"}),Object(r.jsx)(b,{size:"small",loading:o.loading,checked:!1===o.apiListData.disable.includes("/"),onChange:e=>{s((e=>({...kt(e,"loading",!0)}))),jt.post("".concat(gt.baseURL,"/api/changeWebApiStatus/"),{api:"/",val:e}).then((e=>{s((e=>({...kt(e,"loading",!1)}))),i()}))}})]}),width:80,render:function(){const{type:e,path:t,method:a}=arguments.length<=1?void 0:arguments[1],n="".concat(a," ").concat(t);return Object(r.jsxs)("div",{className:"".concat(e," apiType operation"),children:[Object(r.jsx)(p,{className:"btn delete",title:"\u786e\u5b9a\u5220\u9664\u6b64API?",onConfirm:()=>{const e=["paths",t,a];jt.post("".concat(gt.baseURL,"/api/removeApi/"),{setPath:e}).then((e=>{i()}))},okText:"\u662f",cancelText:"\u5426",children:Object(r.jsx)(mt.a,{})}),Object(r.jsx)(j,{type:"vertical"}),Object(r.jsx)(b,{className:"btn switch",size:"small",loading:o.loading,disabled:o.apiListData.disable.includes("/"),checked:!1===o.apiListData.disable.includes(n),onChange:e=>{s((e=>({...kt(e,"loading",!0)}))),jt.post("".concat(gt.baseURL,"/api/changeWebApiStatus/"),{api:n,val:e}).then((e=>{s((e=>({...kt(e,"loading",!1)}))),i()}))}}),Object(r.jsx)(j,{type:"vertical"}),Object(r.jsx)(bt.a,{className:"btn play",onClick:()=>ft({apiPath:t,method:a})})]})},dataIndex:"operation"}];function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};jt.get("".concat(gt.baseURL,"/api/studio/"),{params:e}).then((e=>{const t=e.api.map(((e,t)=>({index:t,...e}))),a=e.disable;s((e=>({...kt(e,"apiListData",{results:t,disable:a})})))}))}return t((()=>{i()}),[]),Object(r.jsx)("div",{className:"ApiList",children:Object(r.jsx)(n,{bordered:!0,size:"small",rowKey:"index",pagination:!1,columns:c,dataSource:o.apiListData.results})})}})();var It=Ct;a(289),a(456);var Rt=function(e){const{onChange:t}=I,{Button:a,Input:n,Modal:s}=d,{useState:c,useImperativeHandle:i,useEffect:l,useRef:p}=o.a,{http:h,cfg:u}=g;i(e.cRef,(()=>({show:j})));const[m,b]=c({text:"",translateRes:[],confirmLoading:!1,enclosure:void 0,isModalVisible:e.isModalVisible});function j(e){b((t=>({...t,isModalVisible:!0,enclosure:e})))}return Object(r.jsx)("div",{children:Object(r.jsx)(s,{title:"\u4ece\u6587\u672c\u81ea\u52a8\u8f6c\u6362",visible:m.isModalVisible,onOk:function(){b((e=>({...e,confirmLoading:!0}))),h.post("".concat(u.baseURL,"/api/translate/"),{text:m.text}).then((t=>{e.onOk({data:t,enclosure:m.enclosure})})).finally((()=>{b((e=>({...e,isModalVisible:!1,confirmLoading:!1})))}))},onCancel:function(){b((e=>({...e,isModalVisible:!1})))},confirmLoading:m.confirmLoading,children:Object(r.jsx)(n.TextArea,{defaultValue:m.text,rows:5,onChange:e=>t(e,"text",{state:m,setState:b})})})})},Tt=a(73),Nt=a(291),Lt=a(137),Pt=a(180),At=a(292),Ut=a(274),Ht=a(290);const{Option:Bt}=Tt.a,{search:qt,setListVal:Et,removeKeys:Jt,guid:zt,getSelectionText:Mt,deepGet:_t,deepSet:Kt,removeEmpty:Ft}=I,$t=o.a.createContext(),Vt=e=>{let{index:t,...a}=e;const[n]=Nt.a.useForm();return Object(r.jsx)(Nt.a,{form:n,component:!1,children:Object(r.jsx)($t.Provider,{value:n,children:Object(r.jsx)("tr",{...a})})})},Wt=e=>{let{title:t,editable:a,children:o,dataIndex:s,record:c,handleSave:i,type:l,...d}=e;const[p,h]=Object(n.useState)(!1),u=Object(n.useRef)(),m=Object(n.useContext)($t);Object(n.useEffect)((()=>{var e;p&&(null===u||void 0===u||null===(e=u.current)||void 0===e||e.focus())}),[p]);const b=()=>{h(!p),m.setFieldsValue({[s]:c[s]})},j=async e=>{try{const e=await m.validateFields(),t={...c,...e};t[s]=""===t[s]?void 0:t[s],i(t)}catch(t){console.log("Save failed:",t)}},g=["string","boolean","number","object","array","eval"],f=async e=>{await j(),b()};let x=o;if(a){const y=c[s];function w(e){const t={style:{margin:0},name:s};return{string:p?Object(r.jsx)(Nt.a.Item,{...t,children:Object(r.jsx)(Lt.a.TextArea,{ref:u,onBlur:f,placeholder:"\u8bf7\u8f93\u5165",autoSize:{minRows:1}})}):Object(r.jsx)("div",{className:"editable-cell-value-wrap",style:{paddingRight:24},onClick:b,children:o.filter((e=>void 0!==e)).length?o:Object(r.jsx)(r.Fragment,{children:"\xa0"})}),boolean:p?Object(r.jsx)(Nt.a.Item,{...t,children:Object(r.jsxs)(Tt.a,{style:{width:"100%"},placeholder:"\u8bf7\u9009\u62e9",onBlur:f,onChange:j,children:[Object(r.jsx)(Bt,{value:!0,children:"\u662f"}),Object(r.jsx)(Bt,{value:!1,children:"\u5426"})]})}):Object(r.jsx)("div",{className:"editable-cell-value-wrap",style:{paddingRight:24},onClick:b,children:{true:"\u662f",false:"\u5426"}[y]||Object(r.jsx)(r.Fragment,{children:"\xa0"})}),array:p?Object(r.jsx)(Nt.a.Item,{...t,children:Object(r.jsx)(Tt.a,{allowClear:!0,style:{width:"100%"},placeholder:"\u8bf7\u9009\u62e9",onBlur:f,onChange:j,children:g.map((e=>{var t;return Object(r.jsx)(Bt,{disabled:!!["string","number"].includes(e)&&(["array","object"].includes(c.type)&&(null===(t=c.children)||void 0===t?void 0:t.length)),value:e,title:{eval:"\u4f7f\u7528 js \u4ee3\u7801\u6267\u884c\u7ed3\u679c"}[e]||e,children:e},e)}))})}):Object(r.jsx)("div",{className:"editable-cell-value-wrap",onClick:b,children:y||Object(r.jsx)(r.Fragment,{children:"\xa0"})})}[e||"string"]}x=w(l)}return Object(r.jsx)("td",{...d,children:x})};var Gt=function(e){const{useState:t,useEffect:a,useRef:n}=o.a,s=n(),[c,l]=t({dataSource:Et({arr:JSON.parse(JSON.stringify(e.dataSource||[{key:zt()}])),key:"key",val:zt,childrenKey:"children"})});a((()=>{if(void 0!==c.dataSource){const t=Ft(Jt(c.dataSource,["key"]));e.dataOnChange(t)}}),[c.dataSource]);const d=e=>{let t=qt(c.dataSource,"key",e);t.pop();const a=Kt([...c.dataSource],t.join("."),void 0,!0);l({dataSource:a})};let p=null;const h=e=>{clearTimeout(p),s.current.show(e)},u=e=>{clearTimeout(p),p=setTimeout((()=>{if(e){e.children=[...e.children||[],{key:zt()}];let t=qt(c.dataSource,"key",e.key);t=t.slice(0,-2),m(e)}else{let{dataSource:e=[]}=c;const t=zt();l({dataSource:[...e,{key:t}]})}}),250)},m=e=>{let t=qt(c.dataSource,"key",e.key);void 0===e.name&&Pt.b.warn("\u5b57\u6bb5\u540d\u5fc5\u586b"),t=t.slice(0,-1);if(_t([...c.dataSource],t.slice(0,-1).join(".")).some((t=>t.key!==e.key&&void 0!==t.name&&t.name===e.name)))return Pt.b.warn("\u5f53\u524d\u5c42\u7ea7\u5df2\u5b58\u5728\u76f8\u540c\u7684\u5b57\u6bb5\u540d ".concat(e.name)),!1;{let a=Kt([...c.dataSource],t.join("."),e);a=Kt(a,t.join("."),{...e,children:!1===["array","object"].includes(e.type)?void 0:e.children}),l({dataSource:a})}},{dataSource:b}=c,j={body:{row:Vt,cell:Wt}},g=[...e.columns,{title:Object(r.jsxs)("div",{children:[Object(r.jsx)(At.a,{title:"\u786e\u8ba4\u5220\u9664\u6240\u6709\u5b57\u6bb5?",onConfirm:()=>{l({dataSource:[]})},children:Object(r.jsx)(i.a,{size:"small",danger:!0,children:"-"})}),Object(r.jsx)(Ut.a,{type:"vertical"}),Object(r.jsx)(i.a,{title:"\u5728\u6839\u7ed3\u70b9\u4e0b\u9762\u6dfb\u52a0\u5b57\u6bb5",size:"small",onClick:()=>u(),onDoubleClick:()=>h(),children:"+"})]}),dataIndex:"operation",width:80,render:(e,t)=>Object(r.jsxs)("div",{children:[Object(r.jsx)(At.a,{title:"\u786e\u8ba4\u5220\u9664?",onConfirm:()=>d(t.key),children:Object(r.jsx)(i.a,{size:"small",onClick:t.name?()=>{}:()=>d(t.key),danger:!0,children:"-"})}),["array","object"].includes(t.type)&&Object(r.jsxs)(r.Fragment,{children:[Object(r.jsx)(Ut.a,{type:"vertical"}),Object(r.jsx)(i.a,{title:"\u5728\u5f53\u524d\u7ed3\u70b9\u4e0b\u9762\u6dfb\u52a0\u5b57\u6bb5",size:"small",onClick:()=>u(t),onDoubleClick:()=>h(t),children:"+"})]})]})}].map((e=>e.editable?{...e,onCell:t=>({type:e.type,record:t,editable:e.editable,dataIndex:e.dataIndex,title:e.title,handleSave:m})}:e));return Object(r.jsxs)("div",{children:[Object(r.jsx)(Rt,{cRef:s,onOk:e=>{let{data:t,enclosure:a}=e;function n(e){const a=e.map((e=>e.name)),n=[],o=t.filter((e=>!a.includes(e.name)||(n.push(e.name),!1))).map((e=>({...e,key:zt()})));return t.length!==o.length&&Pt.b.warn("\u5df2\u8df3\u8fc7\u76f8\u540c\u7684\u5b57\u6bb5: ".concat(n.join(", "))),o}if(t=Et({arr:JSON.parse(JSON.stringify(t)),key:"key",val:zt,childrenKey:"children"}),a){const e=a.children||[];a.children=[...e,...n(e)];let t=qt(c.dataSource,"key",a.key);t=t.slice(0,-2),m(a)}else{let{dataSource:e=[]}=c;l({dataSource:[...e,...n(e)]})}}}),Object(r.jsx)(Ht.a,{...e,pagination:!1,expandable:{defaultExpandAllRows:!0},size:"small",components:j,rowClassName:()=>"editable-row",bordered:!0,dataSource:b,columns:g})]})};const{objOrLine:Xt,debounce:Qt,removeEmpty:Yt,deepGet:Zt,deepSet:ea,showTitle:ta}=I,{http:aa,cfg:na}=g,{Space:oa,Card:sa,Checkbox:ca,message:ia,Alert:ra,Button:la,Menu:da,Dropdown:pa,Tabs:ha,Select:ua,Input:ma}=d,{TabPane:ba}=ha,{Option:ja}=ua;var ga=function(e){const t=e,{useState:a,useEffect:n,useRef:s}=o.a,c=d(),[i,l]=a({type:"object",rule:"",table:e.table,custom:"",tableToStrData:"",getApiIdDetailsRes:{headers:{},data:{}},useDataType:"table",...c});function d(){const t=e.example||{},a=Xt(t.headers||{});return{...t,headers:a}}function p(){l((e=>({...e,...d()})))}function h(e,t){if(null===e)return!1;let a=e;"function"===typeof e.persist?(e.persist(),a=e.target.value):e.target&&void 0!==e.target.checked&&(a=e.target.checked),console.log("valuevaluevalue",a);const n=Zt(i,t);JSON.stringify(n)!==JSON.stringify(a)&&l((e=>({...ea(e,t,a)})))}async function u(){const t=await aa.post("".concat(na.baseURL,"/api/listToData/"),{table:e.table,rule:i.rule,type:i.type}).catch((e=>console.log(e))),a=JSON.stringify(t,null,2);l((e=>({...e,tableToStrData:a})))}function m(){let t,a={...e.example,useDataType:i.useDataType};"table"===i.useDataType&&(a.rule=i.rule,a.type=i.type,a.headers=Xt(i.headers),Object.keys(a.headers).some((e=>{const n=a.headers[e];return"content-type"===e.toLowerCase()&&"application/json"!==n.toLowerCase().trim()?t="table \u6a21\u5f0f\u4e0b\u4ec5\u5141\u8bb8 content-type \u503c\u4e3a application/json":escape(e).includes("%u")&&(t="".concat(e," \u4e0d\u80fd\u542b\u6709\u975e\u82f1\u6587\u5b57\u7b26")),t}))),"custom"===i.useDataType&&(a.custom=i.custom,i.custom||(t="\u8bf7\u8f93\u5165\u81ea\u5b9a\u4e49\u5185\u5bb9")),"history"===i.useDataType&&(a.history=i.history,i.history||(t="\u8bf7\u8f93\u5165\u8bf7\u6c42ID")),t?ia.error(t):e.upLoad(a)}function b(e){return Object(r.jsx)(r.Fragment,{children:Object(r.jsxs)(oa,{children:[Object(r.jsx)(la,{size:"small",onClick:t.close,children:ta("\u53d6\u6d88","\u653e\u5f03\u6240\u6709\u4fee\u6539")}),Object(r.jsx)(la,{size:"small",onClick:p,children:ta("\u91cd\u7f6e","\u4f7f\u7528\u670d\u52a1\u5668\u914d\u7f6e\u91cd\u7f6e")}),Object(r.jsx)(la,{onClick:m,size:"small",children:ta("\u4e0a\u4f20","\u4e0a\u4f20\u5f53\u524d\u914d\u7f6e\u5230\u670d\u52a1\u5668")})]})})}return n((()=>{l((e=>(u(),e)))}),[e.table,i.rule,i.type]),n((()=>{l((e=>(i.history&&aa.get("".concat(na.baseURL,"/api/getApiResponseById,").concat(i.history,"/"),{_raw:!0}).then((e=>{l((t=>({...t,getApiIdDetailsRes:e})))})),e)))}),[i.history]),Object(r.jsxs)(oa,{direction:"vertical",className:"ExampleCom",style:{width:"100%"},children:[Object(r.jsxs)(sa,{size:"small",title:"\u6570\u636e\u6e90",children:[Object(r.jsxs)(ua,{disabled:"req"===t.type,style:{width:"100%"},onChange:e=>h(e,"useDataType"),value:i.useDataType,children:[Object(r.jsx)(ja,{value:"table",children:ta("\u8868\u683c","\u4f7f\u7528\u8868\u683c\u751f\u6210\u6570\u636e")}),Object(r.jsx)(ja,{value:"custom",children:ta("\u81ea\u5b9a\u4e49","\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u5904\u7406\u63a5\u53e3")}),Object(r.jsx)(ja,{disabled:"ws"===t.method,value:"history",children:ta("\u8bf7\u6c42\u5386\u53f2","\u4f7f\u7528\u5df2\u6709\u8bf7\u6c42\u8bb0\u5f55\u7684\u54cd\u5e94")})]}),Object(r.jsx)("p",{}),{history:Object(r.jsxs)(r.Fragment,{children:[Object(r.jsx)(ma,{addonBefore:"\u8bf7\u6c42ID",addonAfter:Object(r.jsx)(la,{size:"small",children:Object(r.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:i.getApiIdDetailsRes.headers["x-test-api"],children:"\u67e5\u770b\u6b64\u8bb0\u5f55"})}),value:i.history,onChange:e=>h(e,"history"),placeholder:"\u533a\u5206\u5927\u5c0f\u5199"}),Object(r.jsx)("p",{}),"\u54cd\u5e94\u5934",Object(r.jsx)(ma.TextArea,{disabled:!0,value:Xt(i.getApiIdDetailsRes.headers),autoSize:{minRows:6,maxRows:12}}),Object(r.jsx)("p",{}),"\u54cd\u5e94\u4f53",Object(r.jsx)(ma.TextArea,{disabled:!0,value:(()=>{const e=i.getApiIdDetailsRes.data;return"string"===typeof e?e:JSON.stringify(e,null,2)})(),autoSize:{minRows:6,maxRows:12}})]}),custom:Object(r.jsx)(r.Fragment,{children:Object(r.jsx)(ma.TextArea,{placeholder:"\u81ea\u5b9a\u4e49\u63a5\u53e3\u54cd\u5e94\u903b\u8f91",value:i.custom,onChange:e=>h(e,"custom"),autoSize:{minRows:6,maxRows:12}})}),table:Object(r.jsxs)(r.Fragment,{children:[Object(r.jsx)(ma,{disabled:"req"===t.type,addonBefore:Object(r.jsxs)(ua,{disabled:"req"===t.type,onChange:e=>h(e,"type"),value:i.type,children:[Object(r.jsx)(ja,{value:"object",children:ta("object","\u4ee5\u5bf9\u8c61\u5f62\u5f0f\u751f\u6210\u6570\u636e")}),Object(r.jsx)(ja,{value:"array",children:ta("array","\u4ee5\u6570\u7ec4\u5f62\u5f0f\u751f\u6210\u6570\u636e")})]}),addonAfter:Object(r.jsx)(la,{size:"small",onClick:u,children:ta("\u793a\u4f8b","\u4f7f\u7528\u6d4f\u89c8\u5668\u4e0a\u7684\u6570\u636e\u8868\u683c\u751f\u6210\u6570\u636e")}),value:i.rule,onChange:e=>h(e,"rule"),placeholder:"\u751f\u6210\u89c4\u5219"}),Object(r.jsx)("p",{}),Object(r.jsx)(ma.TextArea,{disabled:!0,value:i.tableToStrData,autoSize:{minRows:6,maxRows:12}}),Object(r.jsx)("p",{}),Object(r.jsx)(ma.TextArea,{disabled:"ws"===t.hand.method||"req"===t.type,placeholder:"\u54cd\u5e94\u5934, \u6bcf\u884c\u4e00\u4e2a\u952e\u503c\u5bf9:\nkey: val",value:i.headers,onChange:e=>h(e,"headers"),autoSize:{minRows:2,maxRows:6}})]})}[i.useDataType]]}),Object(r.jsx)("p",{}),"res"===t.type&&Object(r.jsx)(b,{})]})},fa=a(82);const{tryApi:xa,getRestcLink:ya,queryParams:wa,removeEmpty:Oa,getSelectionText:va,deepGet:Sa,deepSet:ka}=I,{http:Da,cfg:Ca}=g,{Switch:Ia,Radio:Ra,Drawer:Ta,Menu:Na,Dropdown:La,Card:Pa,Collapse:Aa,Button:Ua,Tabs:Ha,message:Ba,Spin:qa,Table:Ea,Select:Ja,Input:za,Form:Ma,Checkbox:_a,Row:Ka,Col:Fa,Divider:$a}=d,{TabPane:Va}=Ha,{Option:Wa}=Ja;var Ga=function(){const{useState:e,useEffect:t,useRef:a}=o.a,{useHistory:n,useLocation:s}=l;function c(e){var t,a,s,c,i,l,d,p,h,u,m;const{useState:b,useEffect:j,useRef:g,useCallback:f}=o.a,x=n(),y=[{type:"string",title:"\u5b57\u6bb5\u540d",dataIndex:"name",key:"name",editable:!0,ellipsis:!0,width:100},{type:"string",title:"\u793a\u4f8b\u503c",dataIndex:"example",key:"example",editable:!0,ellipsis:!0,width:100},{type:"array",title:"\u7c7b\u578b",dataIndex:"type",key:"type",editable:!0,ellipsis:!0,width:80},{type:"boolean",title:"\u5fc5\u586b",dataIndex:"required",key:"required",editable:!0,ellipsis:!0,width:50},{type:"string",title:"\u63cf\u8ff0",dataIndex:"description",key:"description",editable:!0,ellipsis:!0,width:200}],w=["query","header","path","cookie","form/body"],O=["200","403","404","500"],v=new URL(window.location.href.replace("#","")).searchParams,[S,k]=b({exampleType:"res",showDrawer:"",queryPath:(v.get("path")||"").replace(/(.?)(\?.*)/,"$1"),apiOk:!1,hand:{method:v.get("method")||"get",parameters:"query",responses:"200"},path:"",data:{get:{description:"",parameters:{query:{table:[{}]}},responses:{200:{table:[{}]}}}}}),D=null===S||void 0===S||null===(t=S.hand)||void 0===t?void 0:t.method,C=Object.keys(Oa(JSON.parse(JSON.stringify(S.data)))||{}),I=Object.keys(Oa(JSON.parse(JSON.stringify((null===(a=S.data)||void 0===a||null===(s=a[D])||void 0===s?void 0:s.parameters)||{})))||{}),R=Object.keys(Oa(JSON.parse(JSON.stringify((null===(c=S.data)||void 0===c||null===(i=c[D])||void 0===i?void 0:i.responses)||{})))||{});function T(){k((e=>{var t,a,n,o,s,c;const{table:i=[],example:r={}}={res:(null===(t=e.data)||void 0===t||null===(a=t[e.hand.method])||void 0===a||null===(n=a.responses)||void 0===n?void 0:n[e.hand.responses])||{},req:(null===(o=e.data)||void 0===o||null===(s=o[e.hand.method])||void 0===s||null===(c=s.parameters)||void 0===c?void 0:c[e.hand.parameters])||{}}[e.exampleType||"res"],{rule:l="",type:d="object"}=r||{};return A({rule:l,type:d},e),setTimeout((()=>{if(null===e.path.match(new RegExp("^/.*")))setTimeout((()=>Ba.warn("\u63a5\u53e3\u8def\u5f84\u683c\u5f0f\u9519\u8bef")),0);else{const t={setPath:["paths",e.path],data:e.data};console.log("sendData",t.data),Da.patch("".concat(Ca.baseURL,"/api/studio/"),Oa(JSON.parse(JSON.stringify(t)))).then((t=>{Ba.info("\u4e0a\u4f20\u6210\u529f"),e.path!==e.queryPath&&x.push("/apiStudio/edit?path=".concat(e.path)),console.log(t)}))}}),0),e}))}j((()=>{k((e=>{const t=e.hand.method,a=I[0]||"query",n=R[0]||"200";return{...e,hand:{method:t,parameters:a,responses:n}}}))}),[S.hand.method]),j((()=>{const e=S.queryPath;e&&Da.get("".concat(Ca.baseURL,"/api/studio/?path=").concat(e)).then((t=>{if(!1===Boolean(t))return k((t=>({...t,path:e}))),!1;k((a=>({...a,data:t,path:e})))})).finally((()=>{k((e=>({...e,apiOk:!0})))}))}),[S.queryPath]);const N=window.HotKey;function L(e,t){let a=e;e&&"function"===typeof e.persist&&(e.persist(),a=e.target.value);const n=Sa(S,t);JSON.stringify(n)!==JSON.stringify(a)&&k((e=>({...ka(e,t,a)})))}function P(e){let