UNPKG

goldpankit

Version:

GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。

1 lines 60.8 kB
import{C as U}from"./CompilerSelect-b4a5c1f3.js";import{_ as w,r,o as m,h as y,w as s,b as i,c as k,F as z,j as N,a2 as Y,P as G,K as H,a as o,I as E,t as b,a3 as Z,S as L,e as v,a4 as oe,a5 as A,g as B,M as re,E as ue,k as W,a6 as de,A as J,J as me,a7 as ce,p as x,l as j,z as X,Z as pe,a8 as K}from"./index-98da7881.js";import{h as he,i as fe,j as ee,g as M,k as _e,d as te,l as be}from"./service-83330bd8.js";import{h as ve,j as ge,k as le,e as P,P as ye,s as ie,O as ke,a as Q,l as Ve}from"./PluginSelector-9656ed27.js";import{c as ne}from"./QueryModelView-414b3120.js";import{p as Ce}from"./service.version-5c95d9bb.js";const Se={name:"InputTypeSelect",props:{withGroup:{default:!1}}};function Te(e,t,l,h,n,a){const u=r("el-option"),d=r("el-select");return m(),y(d,{class:"input-type-select"},{default:s(()=>[i(u,{value:"input",label:"Input"}),i(u,{value:"number_input",label:"Number Input"}),i(u,{value:"textarea",label:"Textarea"}),i(u,{value:"select",label:"Select"}),i(u,{value:"checkbox",label:"Checkbox"}),i(u,{value:"radio",label:"Radio"}),i(u,{value:"switch",label:"Switch"}),l.withGroup?N("",!0):(m(),k(z,{key:0},[i(u,{value:"datasource",label:"Data Source"}),i(u,{value:"table",label:"Table"}),i(u,{value:"query_model",label:"Query Model"})],64))]),_:1})}const O=w(Se,[["render",Te],["__scopeId","data-v-72eb8421"]]);const Re={name:"SettingFiles",components:{SortableButton:Y,CompilerSelect:U,InputTypeSelect:O,FormItemTip:G},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{currentNode:null,files:[]}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchFilesApi(){return this.isPlugin?ve:he},saveFileSettingApi(){return this.isPlugin?ge:fe}},methods:{fetchFiles(){this.fetchFilesApi(this.unique).then(e=>{this.files=e.map(t=>(t.withoutIfNotExists=t.withoutIfNotExists==null?!1:t.withoutIfNotExists,t)),H(this.files)}).catch(e=>{this.$tip.apiFailed(e)})},saveFileSetting(){this.saveTimeout!=null&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.saveFileSettingApi({...this.unique,type:this.currentNode.type,path:this.currentNode.path,relativePath:this.currentNode.relativePath,compiler:this.currentNode.compiler,withoutIfNotExists:this.currentNode.withoutIfNotExists,enableExpress:this.currentNode.enableExpress,variables:this.currentNode.variables.filter(e=>e.name.trim().length>0)}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)})},300)},createVariable(){this.currentNode.variables.push({name:"",value:"",compiler:"static",remark:""})},deleteVariable(e){this.currentNode.variables.splice(e,1)},handleNodeClick(e){this.currentNode=e},isFlagFile(e){return e.compiler!=null&&e.compiler!==""||e.withoutIfNotExists!=null&&e.withoutIfNotExists!==!1||e.enableExpress!=null&&e.enableExpress!==""||this.__hasFlagFile(e.children)},__hasFlagFile(e){if(e==null||e.length===0)return!1;for(const t of e)if(this.isFlagFile(t))return!0;return!1}},created(){this.fetchFiles()}},Ie={class:"tree"},we={class:"files-wrap"},Ne={class:"search-wrap"},$e={class:"node-label"},Fe={class:"file-setting"},ze={class:"content-wrap"},qe={key:1,class:"setting-holder"},De={class:"holder-wrap"};function Ue(e,t,l,h,n,a){const u=r("el-input"),d=r("Document"),f=r("el-icon"),C=r("Folder"),I=r("el-tree"),_=r("CompilerSelect"),T=r("el-form-item"),R=r("el-switch"),F=r("FormItemTip"),g=r("el-form");return m(),k("div",Ie,[o("div",we,[o("div",Ne,[i(u,{placeholder:e.$t("service.settings.file.filterKeyword")},null,8,["placeholder"])]),i(I,{data:n.files,"highlight-current":!0,"empty-text":e.$t("service.settings.file.noFiles"),onNodeClick:a.handleNodeClick},{default:s(({node:p,data:$})=>[o("span",$e,[$.type==="FILE"?(m(),y(f,{key:0},{default:s(()=>[i(d)]),_:1})):$.type==="DIRECTORY"?(m(),y(f,{key:1},{default:s(()=>[i(C)]),_:1})):N("",!0),o("span",{class:E(["filename",{"flag-file":a.isFlagFile($)}])},b($.label),3)])]),_:1},8,["data","empty-text","onNodeClick"])]),o("div",Fe,[o("h4",null,b(e.$t("service.settings.file.fileSetting")),1),o("div",ze,[n.currentNode!=null?(m(),y(g,{key:0},{default:s(()=>[i(T,{label:e.$t("service.settings.file.compiler")},{default:s(()=>[i(_,{modelValue:n.currentNode.compiler,"onUpdate:modelValue":t[0]||(t[0]=p=>n.currentNode.compiler=p),onChange:a.saveFileSetting},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(T,{label:"只有文件在项目中存在时才生效"},{default:s(()=>[i(R,{modelValue:n.currentNode.withoutIfNotExists,"onUpdate:modelValue":t[1]||(t[1]=p=>n.currentNode.withoutIfNotExists=p),onChange:a.saveFileSetting},null,8,["modelValue","onChange"])]),_:1}),i(T,{label:"启用表达式"},{default:s(()=>[i(u,{modelValue:n.currentNode.enableExpress,"onUpdate:modelValue":t[2]||(t[2]=p=>n.currentNode.enableExpress=p),type:"textarea",rows:8,placeholder:e.$t("service.settings.file.enableExpressHolder"),onInput:a.saveFileSetting},null,8,["modelValue","placeholder","onInput"]),n.currentNode.type==="FILE"?(m(),y(F,{key:0,content:"当表达式结果为true字符串时,才会保留该文件!"})):(m(),y(F,{key:1,content:"当表达式结果为true字符串时,会保留该目录下的子文件/目录,但依然会移除该目录!否则整个目录都会被删除!"}))]),_:1})]),_:1})):(m(),k("div",qe,[o("div",De,[o("h5",null,b(e.$t("service.settings.file.fileSetting")),1),o("p",null,b(e.$t("service.settings.file.fileSettingHolder")),1)])]))])])])}const Kl=w(Re,[["render",Ue],["__scopeId","data-v-8d90c0b4"]]);const Ee={name:"InitializeView",components:{DatabaseTypeSelect:Z,CompilerSelect:U,DirectorySelect:L},props:{spaceName:{required:!0},serviceName:{required:!0},serviceLabel:{required:!1},pluginName:{required:!1},pluginLabel:{required:!1}},data(){return{form:{space:this.spaceName,name:null,version:"1.0.0",compiler:"static",supportedDatabases:[],codespace:""}}},computed:{isInitPlugin(){return this.pluginName!=null}},methods:{initialize(){let e;this.isInitPlugin?e=le({...this.form,service:this.serviceName,name:this.pluginName,label:this.pluginLabel}):e=ee({...this.form,name:this.serviceName,label:this.serviceLabel}),e.then(()=>{this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},fetchConfig(e){let t;this.isInitPlugin?(console.log("查询插件配置",e),t=P({codespace:e})):t=M({codespace:e}),t.then(l=>{l!=null&&(this.form.version=l.version||this.form.version,this.form.compiler=l.compiler||this.form.compiler,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases)}).catch(l=>{this.$tip.apiFailed(l)})}}},xe={class:"initialize-wrap"},je={class:"tip"},Me={class:"directory-select-wrap"},Pe={class:"opera-bottom"};function Oe(e,t,l,h,n,a){const u=r("DirectorySelect"),d=r("el-button");return m(),k("div",xe,[o("div",je,[o("h3",null,b(e.$t("service.settings.initialize.initializeService")),1),o("p",null,b(e.$t("service.settings.initialize.initializeServiceTip")),1)]),o("div",Me,[i(u,{modelValue:n.form.codespace,"onUpdate:modelValue":t[0]||(t[0]=f=>n.form.codespace=f),title:e.$t("service.settings.initialize.selectServiceCodespace"),height:"235px",onChange:a.fetchConfig},null,8,["modelValue","title","onChange"])]),o("div",Pe,[i(d,{type:"primary",onClick:a.initialize},{default:s(()=>[v(b(e.$t("service.settings.initialize.initializeService")),1)]),_:1},8,["onClick"])])])}const Yl=w(Ee,[["render",Oe],["__scopeId","data-v-315f5e85"]]);const Ae={name:"BuildCommandTypeSelect"};function Be(e,t,l,h,n,a){const u=r("el-option"),d=r("el-select");return m(),y(d,{class:"build-command-type-select"},{default:s(()=>[i(u,{value:"Node",label:"Node"}),i(u,{value:"MySQL",label:"MySQL"}),i(u,{value:"Markdown",label:"Markdown"})]),_:1})}const We=w(Ae,[["render",Be],["__scopeId","data-v-3ad07c21"]]);const Ge={name:"ServiceFileSelectWindow",props:{title:{default:"选择文件"},serviceConfig:{required:!0}},data(){return{visible:!1,paths:[],files:[],selectedFilepath:null}},methods:{open(){console.log("open"),this.visible=!0,this.paths=[this.__getProjectName()],this.__fetchFiles(),this.selectedFilepath=null},confirmSelect(){this.visible=!1;let e=`${this.paths.slice(1).join("/")}/${this.selectedFilepath}`;e.startsWith("/")||(e="/"+e),this.$emit("change",e)},cancelSelect(){this.visible=!1},changePath(e){if(e===this.paths.length-1)return;const t=this.paths.slice(0,e+1);this.__fetchFiles(t,()=>{this.paths.splice(e+1),this.selectedFilepath=null})},openOrSelectFile(e){if(e.type==="DIRECTORY"){const t=JSON.parse(JSON.stringify(this.paths));t.push(e.path),this.__fetchFiles(t,()=>{this.paths.push(e.path),this.selectedFilepath=null});return}this.selectedFilepath=e.path},__fetchFiles(e,t){oe(this.__getAbsolutePath(e)).then(l=>{this.files=l,H(this.files),t&&t()}).catch(l=>{this.$tip.apiFailed(l)})},__getProjectName(){return A.split(this.serviceConfig.codespace).pop()},__getAbsolutePath(e){e==null&&(e=JSON.parse(JSON.stringify(this.paths))),e.shift();let t=A.join([this.serviceConfig.codespace,...e]);return(this.serviceConfig.translator.filepath!=null&&this.serviceConfig.translator.filepath.trim()!==""||this.serviceConfig.translator.content!=null&&this.serviceConfig.translator.content.trim()!=="")&&(t=A.join([this.serviceConfig.codespace,this.serviceConfig.translator.output,...e])),t}}},Le=["id"],Je={class:"paths"},Qe=["onClick"],Ke={class:"files"},Ye=["onClick"],He={class:"opera"};function Ze(e,t,l,h,n,a){const u=r("el-button"),d=r("Folder"),f=r("Document"),C=r("el-icon"),I=r("el-dialog");return m(),y(I,{modelValue:n.visible,"onUpdate:modelValue":t[0]||(t[0]=_=>n.visible=_),"show-close":!1,class:"service-file-select-window","append-to-body":""},{header:s(({close:_,titleId:T,titleClass:R})=>[o("h4",{id:T,class:E(R)},b(l.title),11,Le),i(u,{class:"button-icon",icon:"Refresh",onClick:a.__fetchFiles},null,8,["onClick"])]),default:s(()=>[o("ul",Je,[(m(!0),k(z,null,B(n.paths,(_,T)=>(m(),k("li",{key:_,onClick:R=>a.changePath(T)},b(_),9,Qe))),128))]),o("div",Ke,[o("ul",null,[(m(!0),k(z,null,B(n.files,_=>(m(),k("li",{key:_.path,class:E({"is-file":_.type==="FILE",selected:n.selectedFilepath===_.path}),onClick:T=>a.openOrSelectFile(_)},[i(C,null,{default:s(()=>[_.type==="DIRECTORY"?(m(),y(d,{key:0})):(m(),y(f,{key:1}))]),_:2},1024),o("p",null,b(_.path),1)],10,Ye))),128))])]),o("div",He,[i(u,{onClick:a.cancelSelect},{default:s(()=>[v("Cancel")]),_:1},8,["onClick"]),i(u,{type:"primary",disabled:n.selectedFilepath==null,onClick:a.confirmSelect},{default:s(()=>[v("Confirm Select")]),_:1},8,["disabled","onClick"])])]),_:1},8,["modelValue"])}const Xe=w(Ge,[["render",Ze]]);const et={name:"BuildList",components:{ServiceFileSelectWindow:Xe,DirectorySelect:L,MarkdownEditor:re,Empty:ue,BuildCommandTypeSelect:We},props:{builds:{required:!0,type:Array},withUnbuild:{default:!1},serviceConfig:{required:!0}},data(){return{actives:[],varIndex:1,selectFileData:{currentBuild:null}}},watch:{builds:{immediate:!0,handler(){this.__handleBuildList("builds")}},unbuilds:{immediate:!0,handler(){this.__handleBuildList("unbuilds")}}},methods:{handleKeypress(e){console.log(e.keyCode),e.stopPropagation()},handleFileChange(e){this.selectFileData.currentBuild.__filepath=e,this.handleSave()},create(){const e=""+Math.random();this.builds.push({id:e,name:this.__generateBuildName(),type:"Node",contentType:"string",content:"",__readonly:!1,__filepath:""}),this.actives.push(e)},handleChangeType(e,t){t==="Markdown"&&(e.contentType="string"),this.handleSave()},handleSave(){this.$emit("save")},deleteBuild(e){this.builds.splice(e,1),this.handleSave()},openSelectFileWindow(e){this.selectFileData.currentBuild=e,this.$refs.serviceFileSelectWindow.open()},__generateBuildName(){let e;for(;;)if(e=`${this.withUnbuild?"un":""}build${this.varIndex}`,this.varIndex++,this.builds.findIndex(t=>t.name===e)===-1)return e},__handleBuildList(e){this[e]!=null&&this[e].forEach(t=>{t.id=""+Math.random(),t.contentType==="file"&&(t.__filepath=t.content,t.content=""),t.__readonly=!0})}}},tt={class:"service-build-list"},lt={class:"toolbar"},it={key:0},nt={key:1},at={class:"title-wrap"},st={class:"opera"},ot=["onClick"],rt={key:0,class:"holder"},ut={key:1},dt={key:1,class:"markdown-wrap"};function mt(e,t,l,h,n,a){const u=r("el-button"),d=r("el-input"),f=r("el-form-item"),C=r("BuildCommandTypeSelect"),I=r("el-form"),_=r("el-tab-pane"),T=r("el-tabs"),R=r("MarkdownEditor"),F=r("Empty"),g=r("ServiceFileSelectWindow");return m(),k("div",tt,[o("div",lt,[l.withUnbuild?(m(),k("p",it,b(e.$t("service.settings.build.unBuildTip")),1)):(m(),k("p",nt,b(e.$t("service.settings.build.buildTip")),1)),i(u,{type:"primary",onClick:a.create},{default:s(()=>[v(b(e.$t("common.create")),1)]),_:1},8,["onClick"])]),l.builds.length>0?(m(!0),k(z,{key:0},B(l.builds,(p,$)=>(m(),k("ul",{key:p.id},[o("li",null,[o("div",at,[i(I,{model:p},{default:s(()=>[i(f,{label:"名称",required:""},{default:s(()=>[i(d,{class:"name",modelValue:p.name,"onUpdate:modelValue":c=>p.name=c,onClick:t[0]||(t[0]=W(()=>{},["stop"])),onKeypress:a.handleKeypress,onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","onKeypress","onInput"])]),_:2},1024),i(f,{label:"类型",class:"build-type",required:""},{default:s(()=>[i(C,{class:"type",modelValue:p.type,"onUpdate:modelValue":c=>p.type=c,onChange:c=>a.handleChangeType(p,c)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1024)]),_:2},1032,["model"]),o("div",st,[i(u,{icon:"Delete",link:"",type:"danger",onClick:W(c=>a.deleteBuild($),["stop"])},{default:s(()=>[v(b(e.$t("common.delete")),1)]),_:2},1032,["onClick"])])]),p.type!=="Markdown"?(m(),y(T,{key:0,modelValue:p.contentType,"onUpdate:modelValue":c=>p.contentType=c},{default:s(()=>[i(_,{name:"string",label:"文本"},{default:s(()=>[i(d,{modelValue:p.content,"onUpdate:modelValue":c=>p.content=c,type:"textarea",placeholder:e.$t("service.settings.build.buildCommand"),rows:5,onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","placeholder","onInput"])]),_:2},1024),i(_,{name:"file",label:"文件"},{default:s(()=>[o("div",{class:"select-holder",onClick:c=>a.openSelectFileWindow(p)},[p.__filepath==null||p.__filepath===""?(m(),k("p",rt,b(e.$t("common.clickToSelectFile")),1)):(m(),k("p",ut,b(p.__filepath),1))],8,ot)]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"])):(m(),k("div",dt,[i(R,{modelValue:p.content,"onUpdate:modelValue":c=>p.content=c,placeholder:"输入内容将作为构建步骤进行展示",onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]))])]))),128)):(m(),y(F,{key:1})),i(g,{ref:"serviceFileSelectWindow","service-config":l.serviceConfig,onChange:a.handleFileChange},null,8,["service-config","onChange"])])}const ct=w(et,[["render",mt],["__scopeId","data-v-5a5d45ab"]]);function pt(){return new Worker("/assets/editor.worker-9a091e5f.js")}function ht(){return new Worker("/assets/ts.worker-6f3611ff.js")}self.MonacoEnvironment={getWorker(e,t){return t==="typescript"||t==="javascript"?new ht:new pt}};const ft={name:"Translator",props:{data:{required:!0}},data(){return{saveTimeout:null,filepathCodeEditor:{fullscreen:!1},contentCodeEditor:{fullscreen:!1}}},methods:{handleSave(){this.saveTimeout!=null&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.$emit("save")},300)},exitFullScreen(){this.filepathCodeEditor.fullscreen=!1,this.contentCodeEditor.fullscreen=!1},__initEditor(e,t){const l=de.create(document.querySelector(e),{value:this.data[t],language:"javascript",tabSize:2,readOnly:!1,automaticLayout:!0,fontSize:15,minimap:{enabled:!0}});l.onDidChangeModelContent(h=>{this.data[t]=l.getValue(),this.handleSave()})}},mounted(){this.__initEditor(".translator .filepath-code-editor","filepath"),this.__initEditor(".translator .content-code-editor","content"),document.addEventListener("keydown",e=>{e.key==="Escape"&&this.exitFullScreen()})}},S=e=>(x("data-v-1dfe6d18"),e=e(),j(),e),_t={class:"translator"},bt={class:"translator-item"},vt=S(()=>o("h3",null,"文件路径翻译函数",-1)),gt={class:"code"},yt=S(()=>o("em",null,"function",-1)),kt=S(()=>o("em",null,"(",-1)),Vt=S(()=>o("span",null,": 文件路径",-1)),Ct=S(()=>o("span",null,": 文件名",-1)),St=S(()=>o("span",null,": 文件后缀",-1)),Tt=S(()=>o("em",null,")",-1)),Rt=S(()=>o("em",null,"{",-1)),It=S(()=>o("p",null,"}",-1)),wt={class:"translator-item"},Nt=S(()=>o("h3",null,"文件内容翻译函数",-1)),$t={class:"code"},Ft=S(()=>o("em",null,"function",-1)),zt=S(()=>o("em",null,"(",-1)),qt=S(()=>o("span",null,": 文件路径",-1)),Dt=S(()=>o("span",null,": 文件名",-1)),Ut=S(()=>o("span",null,": 文件后缀",-1)),Et=S(()=>o("span",null,": 文件设置",-1)),xt=S(()=>o("br",null,null,-1)),jt=S(()=>o("span",null,": 文件内容",-1)),Mt=S(()=>o("em",null,")",-1)),Pt=S(()=>o("em",null,"{",-1)),Ot=S(()=>o("p",null,"}",-1)),At={class:"toolbar"};function Bt(e,t,l,h,n,a){const u=r("el-button");return m(),k("div",_t,[o("div",bt,[vt,o("p",gt,[yt,v(" translate "),kt,v("filepath"),Vt,v(", filename"),Ct,v(", suffix"),St,Tt,v(),Rt,i(u,{type:"primary",onClick:t[0]||(t[0]=d=>n.filepathCodeEditor.fullscreen=!n.filepathCodeEditor.fullscreen)},{default:s(()=>[v("全屏")]),_:1})]),o("div",{class:E(["editor filepath-code-editor",{fullscreen:n.filepathCodeEditor.fullscreen}])},null,2),It]),o("div",wt,[Nt,o("p",$t,[Ft,v(" translate "),zt,v("filepath"),qt,v(", filename"),Dt,v(", suffix"),Ut,v(", setting"),Et,v(","),xt,v("     content"),jt,Mt,v(),Pt,i(u,{type:"primary",onClick:t[1]||(t[1]=d=>n.contentCodeEditor.fullscreen=!n.contentCodeEditor.fullscreen)},{default:s(()=>[v("全屏")]),_:1})]),o("div",{class:E(["editor content-code-editor",{fullscreen:n.contentCodeEditor.fullscreen}])},null,2),Ot]),J(o("div",At,[o("h3",null,b(n.filepathCodeEditor.fullscreen?"文件路径编译函数":"文件内容编译函数"),1),o("img",{src:ce,onClick:t[2]||(t[2]=(...d)=>a.exitFullScreen&&a.exitFullScreen(...d))})],512),[[me,n.filepathCodeEditor.fullscreen||n.contentCodeEditor.fullscreen]])])}const Wt=w(ft,[["render",Bt],["__scopeId","data-v-1dfe6d18"]]);const Gt={name:"BasicSetting",components:{Translator:Wt,FormItemTip:G,BuildList:ct,DirectorySelect:L,DatabaseTypeSelect:Z,CompilerSelect:U,PluginSelector:ye},props:{space:{required:!0},service:{required:!0},plugin:{required:!1},serviceConfig:{}},data(){return{isWorking:{clone:!1},newCodespace:{changing:!1,value:""},originForm:null,form:{name:"",label:"",version:"",minServiceVersion:"",private:!1,receivable:!1,compiler:"",introduce:"",presetPlugins:[],repository:"",branch:"",supportedDatabases:[],tableFieldDefinitions:[],builds:[],unbuilds:[],prices:[{type:"free",value:0}],translator:{output:"",settings:[]},codespace:""}}},computed:{isPlugin(){return this.plugin!=null},clonable(){return this.form.repository.trim()!==""&&this.form.branch.trim()!==""},majorVersion(){return this.form.version.trim()===""?"":this.form.version.split(".")[0]}},methods:{initData(){for(const e in this.form)e==="label"&&(this.form.label=this.serviceConfig.label||this.serviceConfig.name||this.form.label),this.form[e]=this.serviceConfig[e]||this.form[e];this.form.translator!=null&&(this.form.translator.filepath=this.form.translator.filepath||"",this.form.translator.content=this.form.translator.content||"",this.form.translator.settings&&delete this.form.translator.settings),this.form.presetPlugins===void 0&&(this.form.presetPlugins=[]),this.originForm=JSON.parse(JSON.stringify(this.form))},initialize(){this.form.codespace=this.newCodespace.value;let e;this.isPlugin?e=le({space:this.space,service:this.service,name:this.plugin,...this.form}):e=ee({space:this.space,name:this.service,...this.form}),e.then(()=>{this.newCodespace.changing=!1,this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},handleBranchInput(e){(e.startsWith("v")||e.startsWith("V"))&&(e=e.substring(1)),ne(null,e,t=>{t||(this.form.version=e),this.saveConfig()})},clone(){this.isWorking.clone||this.alert(this.$t("gitClone.cloneTip"),this.$t("common.importantTip"),{showCancelButton:!0,cancelButtonText:this.$t("common.cancel"),confirmButtonText:this.$t("gitClone.confirm"),confirmButtonClass:"danger-button"}).then(()=>{this.isWorking.clone=!0,_e({space:this.space,service:this.service,plugin:this.plugin}).then(()=>{this.alert(this.$t("gitClone.cloneSuccess")).then(()=>{window.location.reload()}).catch(()=>{})}).catch(e=>{this.alert(this.$t("gitClone.cloneFailed",{message:e.message}),this.$t("gitClone.cloneFailedTitle")).catch(()=>{})}).finally(()=>{this.isWorking.clone=!1})}).catch(()=>{})},changePriceType(e){e==="free"&&(this.form.prices[0].value=0),this.saveConfig()},changeCodespace(){this.newCodespace.changing=!0,this.newCodespace.value=this.form.codespace},fetchConfig(e){let t;this.isPlugin?t=P({codespace:e}):t=M({codespace:e}),t.then(l=>{l!=null&&(this.form.name=l.name||this.form.name,this.form.label=l.label||l.name||this.form.label,this.form.version=l.version||this.form.version,this.form.minServiceVersion=l.minServiceVersion||this.form.minServiceVersion,this.form.introduce=l.introduce||this.form.introduce,this.form.compiler=l.compiler||this.form.compiler,this.form.prices=l.prices||this.form.prices,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases,this.form.builds=l.builds||this.form.builds,this.form.unbuilds=l.unbuilds||this.form.unbuilds,this.form.translator=l.translator||this.form.translator)}).catch(l=>{this.$tip.apiFailed(l)})},saveConfig(){if(this.newCodespace.changing)return;let e,t;this.isPlugin?(t=ie,e={space:this.space,service:this.service,plugin:this.plugin}):(t=te,e={space:this.space,service:this.service},delete this.form.minServiceVersion),t({...e,...this.form,builds:this.form.builds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType})),unbuilds:this.form.unbuilds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType}))}).then(()=>{this.originForm=JSON.parse(JSON.stringify(this.form))}).catch(l=>{this.$tip.apiFailed(l)})}},created(){this.initData()}},Lt=e=>(x("data-v-d4318ea4"),e=e(),j(),e),Jt={class:"basic-setting"},Qt={class:"wrap"},Kt={class:"repository-input-wrap"},Yt=Lt(()=>o("span",null,"/",-1)),Ht={key:0,class:"codespace-wrap"},Zt={key:0,class:"opera-wrap"};function Xt(e,t,l,h,n,a){const u=r("el-input"),d=r("el-form-item"),f=r("FormItemTip"),C=r("CompilerSelect"),I=r("DatabaseTypeSelect"),_=r("el-button"),T=r("PluginSelector"),R=r("el-checkbox"),F=r("Translator"),g=r("BuildList"),p=r("DirectorySelect"),$=r("el-form");return m(),k("div",Jt,[o("div",Qt,[i($,{model:n.form},{default:s(()=>[l.plugin==null?(m(),k(z,{key:0},[i(d,{label:e.$t("service.settings.name"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.name,"onUpdate:modelValue":t[0]||(t[0]=c=>n.form.name=c),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.label"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.label,"onUpdate:modelValue":t[1]||(t[1]=c=>n.form.label=c),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)):(m(),k(z,{key:1},[i(d,{label:e.$t("plugin.name"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.name,"onUpdate:modelValue":t[2]||(t[2]=c=>n.form.name=c),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),i(d,{label:e.$t("plugin.label"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.label,"onUpdate:modelValue":t[3]||(t[3]=c=>n.form.label=c),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)),i(d,{label:e.$t("service.settings.version"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.version,"onUpdate:modelValue":t[4]||(t[4]=c=>n.form.version=c),onInput:a.saveConfig},null,8,["modelValue","onInput"]),i(f,{content:"如1.0.0.0,其中最后一个版本号不触发升级提醒!"})]),_:1},8,["label"]),a.isPlugin?(m(),y(d,{key:2,label:"最低兼容的服务版本号",prop:"minServiceVersion"},{default:s(()=>[i(u,{modelValue:n.form.minServiceVersion,"onUpdate:modelValue":t[5]||(t[5]=c=>n.form.minServiceVersion=c),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1})):N("",!0),i(d,{label:e.$t("service.settings.compiler"),prop:"compiler",required:""},{default:s(()=>[i(C,{modelValue:n.form.compiler,"onUpdate:modelValue":t[6]||(t[6]=c=>n.form.compiler=c),onChange:a.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.supportedDatabases"),prop:"supportedDatabases"},{default:s(()=>[i(I,{modelValue:n.form.supportedDatabases,"onUpdate:modelValue":t[7]||(t[7]=c=>n.form.supportedDatabases=c),onChange:a.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.repository"),prop:"repository"},{default:s(()=>[o("div",Kt,[i(u,{class:"repository-input",modelValue:n.form.repository,"onUpdate:modelValue":t[8]||(t[8]=c=>n.form.repository=c),onInput:a.saveConfig},null,8,["modelValue","onInput"]),Yt,i(u,{class:"branch-input",modelValue:n.form.branch,"onUpdate:modelValue":t[9]||(t[9]=c=>n.form.branch=c),placeholder:e.$t("gitClone.branch"),onInput:a.handleBranchInput},null,8,["modelValue","placeholder","onInput"]),i(_,{type:"primary",disabled:n.isWorking.clone||!a.clonable,loading:n.isWorking.clone,onClick:a.clone},{default:s(()=>[v(b(e.$t("gitClone.clone")),1)]),_:1},8,["disabled","loading","onClick"])])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.introduce"),prop:"introduce",required:""},{default:s(()=>[i(u,{type:"textarea",rows:5,modelValue:n.form.introduce,"onUpdate:modelValue":t[10]||(t[10]=c=>n.form.introduce=c),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),l.plugin==null?(m(),y(d,{key:3,label:"预置插件",prop:"presetPlugins",required:""},{default:s(()=>[i(T,{modelValue:n.form.presetPlugins,"onUpdate:modelValue":t[11]||(t[11]=c=>n.form.presetPlugins=c),space:l.space,service:l.service,"major-version":a.majorVersion,onChange:a.saveConfig},null,8,["modelValue","space","service","major-version","onChange"]),i(f,{content:"预置插件会在安装服务时自动安装!"})]),_:1})):N("",!0),i(d,{label:e.$t("service.settings.otherSettings"),class:"item-other-settings"},{default:s(()=>[o("div",null,[i(R,{modelValue:n.form.private,"onUpdate:modelValue":t[12]||(t[12]=c=>n.form.private=c),label:"私有",onChange:a.saveConfig},null,8,["modelValue","onChange"])])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.translator.translator"),prop:"translator"},{default:s(()=>[i(F,{data:n.form.translator,onSave:a.saveConfig},null,8,["data","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.installBuilds"),prop:"builds"},{default:s(()=>[i(g,{builds:n.form.builds,"service-config":l.serviceConfig,onSave:a.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.uninstallBuilds"),prop:"unbuilds"},{default:s(()=>[i(g,{builds:n.form.unbuilds,"with-unbuild":!0,"service-config":l.serviceConfig,onSave:a.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.codespace"),prop:"codespace"},{default:s(()=>[n.newCodespace.changing?(m(),y(p,{key:1,title:e.$t("service.settings.selectNewCodespace"),modelValue:n.newCodespace.value,"onUpdate:modelValue":t[13]||(t[13]=c=>n.newCodespace.value=c),onChange:a.fetchConfig},null,8,["title","modelValue","onChange"])):(m(),k("div",Ht,[o("p",null,b(n.form.codespace),1),i(_,{type:"primary",onClick:a.changeCodespace},{default:s(()=>[v(b(e.$t("service.settings.changeCodespace")),1)]),_:1},8,["onClick"])]))]),_:1},8,["label"])]),_:1},8,["model"]),n.newCodespace.changing?(m(),k("div",Zt,[i(_,{onClick:t[14]||(t[14]=c=>n.newCodespace.changing=!1)},{default:s(()=>[v(b(e.$t("common.cancel")),1)]),_:1}),i(_,{type:"primary",onClick:a.initialize},{default:s(()=>[v(b(e.$t("service.settings.reinitialize")),1)]),_:1},8,["onClick"])])):N("",!0)])])}const Hl=w(Gt,[["render",Xt],["__scopeId","data-v-d4318ea4"]]),el={name:"PublishWindow",components:{FormItemTip:G},data(){return{visible:!1,isWorking:!1,space:null,service:null,plugin:null,form:{version:"",publishDescription:""}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchConfigApi(){return this.isPlugin?M:P},saveConfigApi(){return this.isPlugin?ie:te}},methods:{open(e,t,l){this.space=e,this.service=t,this.plugin=l,this.visible=!0,this.fetchConfig()},getRules(){return{version:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionNumber")})},{validator:ne,message:this.$t("form.isIncorrect",{field:this.$t("service.versionNumber")})}],publishDescription:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionDescription")})}]}},fetchConfig(){this.fetchConfigApi(this.unique).then(e=>{this.form.version=e.version}).catch(e=>{this.$tip.apiFailed(e)})},saveConfig(){this.saveConfigApi({...this.unique,version:this.form.version}).catch(e=>{this.$tip.apiFailed(e)})},publish(){this.$refs.form.validate().then(()=>{this.isWorking||(this.isWorking=!0,Ce({...this.unique,publishDescription:this.form.publishDescription}).then(()=>{this.visible=!1,this.$message.success("发布成功")}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.isWorking=!1}))})}}},tl={class:"dialog-footer"};function ll(e,t,l,h,n,a){const u=r("el-input"),d=r("FormItemTip"),f=r("el-form-item"),C=r("el-form"),I=r("el-button"),_=r("el-dialog"),T=X("loading");return m(),y(_,{modelValue:n.visible,"onUpdate:modelValue":t[3]||(t[3]=R=>n.visible=R),class:"publish-window",title:e.$t("service.settings.publishVersion"),width:"500px",draggable:"","close-on-press-escape":!1,"close-on-click-modal":!1},{footer:s(()=>[o("span",tl,[i(I,{disabled:n.isWorking,onClick:t[2]||(t[2]=R=>n.visible=!1)},{default:s(()=>[v(b(e.$t("common.cancel")),1)]),_:1},8,["disabled"]),i(I,{type:"primary",disabled:n.isWorking,onClick:a.publish},{default:s(()=>[v(b(e.$t("service.settings.publish")),1)]),_:1},8,["disabled","onClick"])])]),default:s(()=>[J((m(),y(C,{ref:"form",model:n.form,rules:a.getRules()},{default:s(()=>[i(f,{label:e.$t("service.versionNumber"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.version,"onUpdate:modelValue":t[0]||(t[0]=R=>n.form.version=R),onInput:a.saveConfig},{prefix:s(()=>[v("v")]),_:1},8,["modelValue","onInput"]),i(d,{content:"如1.0.0.0,其中最后一个版本号不触发升级提醒!"})]),_:1},8,["label"]),i(f,{label:e.$t("service.versionDescription"),prop:"publishDescription",required:""},{default:s(()=>[i(u,{type:"textarea",rows:5,modelValue:n.form.publishDescription,"onUpdate:modelValue":t[1]||(t[1]=R=>n.form.publishDescription=R)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model","rules"])),[[T,n.isWorking]])]),_:1},8,["modelValue","title"])}const Zl=w(el,[["render",ll]]);const il={name:"OptionSettingWindow",components:{OptionValueInput:ke},data(){return{visible:!1,option:null}},methods:{open(e){this.option=e,this.visible=!0},add(){this.option.settings.push({label:"",name:"",inputType:"input",required:!0,defaultValue:""})},deleteSetting(e){this.option.settings.splice(e,1),this.emitChange()},emitChange(){this.$emit("change")}}},nl={class:"toolbar"};function al(e,t,l,h,n,a){const u=r("el-button"),d=r("el-input"),f=r("el-table-column"),C=r("el-option"),I=r("el-select"),_=r("el-switch"),T=r("OptionValueInput"),R=r("el-table"),F=r("el-dialog");return m(),y(F,{modelValue:n.visible,"onUpdate:modelValue":t[0]||(t[0]=g=>n.visible=g),title:e.$t("service.settings.variable.optionSettings"),"append-to-body":"",class:"option-setting-window"},{default:s(()=>[o("div",nl,[i(u,{icon:"Plus",type:"primary",onClick:a.add},{default:s(()=>[v(b(e.$t("common.add")),1)]),_:1},8,["onClick"])]),i(R,{data:n.option.settings},{default:s(()=>[i(f,{prop:"label",label:e.$t("service.settings.variable.label")},{default:s(({row:g})=>[i(d,{modelValue:g.label,"onUpdate:modelValue":p=>g.label=p,onInput:a.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(f,{prop:"name",label:e.$t("service.settings.variable.name")},{default:s(({row:g})=>[i(d,{modelValue:g.name,"onUpdate:modelValue":p=>g.name=p,onInput:a.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(f,{prop:"inputType",label:e.$t("service.settings.variable.inputType")},{default:s(({row:g})=>[i(I,{modelValue:g.inputType,"onUpdate:modelValue":p=>g.inputType=p,onChange:a.emitChange},{default:s(()=>[i(C,{value:"input",label:"Input"}),i(C,{value:"number_input",label:"Number Input"}),i(C,{value:"textarea",label:"Textarea"})]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_:1},8,["label"]),i(f,{prop:"required",label:e.$t("service.settings.variable.required")},{default:s(({row:g})=>[i(_,{modelValue:g.required,"onUpdate:modelValue":p=>g.required=p},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),i(f,{prop:"defaultValue",label:e.$t("service.settings.variable.defaultValue")},{default:s(({row:g})=>[i(T,{"option-setting":g,modelValue:g.defaultValue,"onUpdate:modelValue":p=>g.defaultValue=p,onInput:a.emitChange},null,8,["option-setting","modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(f,{width:"60px"},{default:s(({row:g,$index:p})=>[i(u,{icon:"Delete",onClick:$=>a.deleteSetting(p)},null,8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1},8,["modelValue","title"])}const sl=w(il,[["render",al]]),ol={name:"VariableSettingForm",components:{OptionSettingWindow:sl,SortableButton:Y,VariableInput:Q,CompilerSelect:U,InputTypeSelect:O},props:{variable:{required:!0},rootVariable:{required:!0},variableGroup:{default:!1}},computed:{withGroup(){return this.variableGroup!=null}},watch:{"variable.defaultValue":function(){this.handleFieldVariableValues(),this.handleChange()},"variable.name":function(){this.handleFieldVariableValues(),this.handleChange()}},methods:{focus(){this.$refs.labelInput.focus()},handleChange(){this.$emit("change")},handleDefaultValueChange(){this.handleFieldVariableValues(),this.$emit("change")},handleFieldVariableValues(){if(this.rootVariable!==this.variable&&(this.rootVariable.inputType==="query_model"||this.rootVariable.inputType==="table")){for(const e of this.rootVariable.children)if(e.defaultValue!=null)for(const t of e.defaultValue){t[this.variable.name]=this.variable.defaultValue;for(const l in t){if(l==="origin")continue;e.children.find(n=>n.name===l)==null&&!t.origin.hasOwnProperty(l)&&delete t[l]}}}},createOption(){this.variable.options.push({value:"",label:"",remark:"",settings:[]}),this.handleChange()},deleteOption(e){this.variable.options.splice(e,1),this.handleChange()},handleInputTypeChange(){let e=this.variable.defaultValue;if(e!=null&&e.value!=null&&(e=e.value),e instanceof Array&&(e=e[0]),typeof e=="number"&&(e=e+""),this.variable.inputType==="number_input"){let t=Number(parseInt(e));isNaN(t)&&(t=0),this.variable.defaultValue=t}else if(this.variable.inputType==="select"){const t=this.variable.options.find(l=>l.value===e);this.variable.defaultValue={value:t==null?null:e,settings:t==null?[]:t.settings}}else this.variable.inputType==="checkbox"?this.variable.defaultValue=[]:this.variable.inputType==="radio"?this.variable.defaultValue="":this.variable.inputType==="datasource"||this.variable.inputType==="table"||this.variable.inputType==="query_model"?this.variable.defaultValue=null:this.variable.defaultValue=e;this.handleChange()},handleOptionSorted(e){this.variable.options=[],this.$nextTick(()=>{this.variable.options=e,this.handleChange()})}}},rl=o("label",null,"值选项列表",-1),ul={class:"opera"};function dl(e,t,l,h,n,a){const u=r("el-input"),d=r("el-form-item"),f=r("InputTypeSelect"),C=r("el-button"),I=r("SortableButton"),_=r("el-table-column"),T=r("el-table"),R=r("OptionSettingWindow"),F=r("VariableInput"),g=r("el-switch"),p=r("CompilerSelect"),$=r("el-form"),c=X("sortable");return m(),y($,{model:l.variable},{default:s(()=>[i(d,{label:"变量提示",required:""},{default:s(()=>[i(u,{ref:"labelInput",modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=V=>l.variable.label=V),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1}),i(d,{label:"变量名",required:""},{default:s(()=>[i(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=V=>l.variable.name=V),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1}),i(d,{label:"输入类型",required:""},{default:s(()=>[i(f,{modelValue:l.variable.inputType,"onUpdate:modelValue":t[2]||(t[2]=V=>l.variable.inputType=V),"with-group":a.withGroup,onChange:a.handleInputTypeChange},null,8,["modelValue","with-group","onChange"])]),_:1}),l.variable.inputType==="select"||l.variable.inputType==="checkbox"||l.variable.inputType==="radio"?(m(),y(d,{key:0,class:"item-options",required:""},{label:s(()=>[o("div",null,[rl,o("div",ul,[i(C,{size:"default",type:"primary",onClick:a.createOption},{default:s(()=>[v("添加")]),_:1},8,["onClick"])])])]),default:s(()=>[J((m(),y(T,{data:l.variable.options},{default:s(()=>[i(_,{"class-name":"table-column-sortable",width:"30px",fixed:""},{default:s(()=>[i(I)]),_:1}),i(_,{label:"*名称","min-width":"200px"},{default:s(({row:V})=>[i(u,{modelValue:V.label,"onUpdate:modelValue":D=>V.label=D,size:"large",type:"textarea",rows:1,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1}),i(_,{label:"*"+e.$t("service.settings.variable.optionValue"),"min-width":"120px"},{default:s(({row:V})=>[i(u,{modelValue:V.value,"onUpdate:modelValue":D=>V.value=D,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(_,{label:e.$t("common.remark"),"min-width":"150px"},{default:s(({row:V})=>[i(u,{modelValue:V.remark,"onUpdate:modelValue":D=>V.remark=D,type:"textarea",rows:1,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),l.variable.options.length>0?(m(),y(_,{key:0,"min-width":l.variable.inputType==="select"?"120px":"60px",fixed:"right"},{default:s(({row:V,$index:D})=>[l.variable.inputType==="select"?(m(),y(C,{key:0,icon:"Setting",class:"button-icon",onClick:se=>e.$refs.optionSettingWindow.open(V)},null,8,["onClick"])):N("",!0),i(C,{icon:"Delete",class:"button-icon",onClick:se=>a.deleteOption(D)},null,8,["onClick"])]),_:1},8,["min-width"])):N("",!0)]),_:1},8,["data"])),[[c,{handle:".sortable-button",data:l.variable.options,onChange:a.handleOptionSorted},"config"]]),i(R,{ref:"optionSettingWindow",onChange:a.handleChange},null,8,["onChange"])]),_:1})):N("",!0),i(d,{label:"默认值"},{default:s(()=>[i(F,{variable:l.variable,"value-key":"defaultValue",onChange:a.handleDefaultValueChange},null,8,["variable","onChange"])]),_:1}),i(d,{label:e.$t("service.settings.variable.required")},{default:s(()=>[i(g,{modelValue:l.variable.required,"onUpdate:modelValue":t[3]||(t[3]=V=>l.variable.required=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.variable.hidden")},{default:s(()=>[i(g,{modelValue:l.variable.hidden,"onUpdate:modelValue":t[4]||(t[4]=V=>l.variable.hidden=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),l.variable.inputType!=="number_input"&&l.variable.inputType!=="table"&&l.variable.inputType!=="query_model"&&l.variable.inputType!=="datasource"&&l.rootVariable.inputType!=="query_model"&&l.rootVariable.inputType!=="table"?(m(),y(d,{key:1,label:"编译器"},{default:s(()=>[i(p,{modelValue:l.variable.compiler,"onUpdate:modelValue":t[5]||(t[5]=V=>l.variable.compiler=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1})):N("",!0),i(d,{label:e.$t("common.remark")},{default:s(()=>[i(u,{modelValue:l.variable.remark,"onUpdate:modelValue":t[6]||(t[6]=V=>l.variable.remark=V),type:"textarea",rows:3,onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const ml=w(ol,[["render",dl]]),cl={name:"VariableGroupSettingForm",components:{VariableInput:Q,CompilerSelect:U,InputTypeSelect:O},props:{variable:{required:!0}},methods:{changeScope(){if(this.variable.type==="group")for(const e of this.variable.children)e.scope=this.variable.scope;this.handleChange()},handleChange(){this.$emit("change")}}};function pl(e,t,l,h,n,a){const u=r("el-input"),d=r("el-form-item"),f=r("el-form");return m(),y(f,{model:l.variable},{default:s(()=>[i(d,{label:e.$t("service.settings.variable.groupLabel"),required:""},{default:s(()=>[i(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=C=>l.variable.label=C),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.variable.groupName"),required:""},{default:s(()=>[i(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=C=>l.variable.name=C),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const hl=w(cl,[["render",pl]]);const fl={name:"Variables",components:{VariableGroupSettingForm:hl,VariableSettingForm:ml,VariableInput:Q,I18nInput:pe,InputTypeSelect:O,CompilerSelect:U},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{isWorking:{save:!1},timeout:{save:null},varIndex:1,groupIndex:1,currentVariable:null,currentGroup:null,currentRootVariable:null,variables:[],dragData:{target:null}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},saveVariablesApi(){return this.isPlugin?Ve:be},fetchConfigApi(){return this.isPlugin?P:M}},methods:{selectVariable(e,t){this.currentVariable=null,this.$nextTick(()=>{this.currentVariable=e,this.currentGroup=null,this.currentRootVariable=null,t.level>2?(this.currentRootVariable=t.parent.parent.data,this.currentGroup=t.parent.data):t.level>1?(this.currentRootVariable=t.parent.data,this.currentGroup=t.parent.data):this.currentRootVariable=t.data})},createChild(e){if(e.type==="group"){this.createVariable(e);return}if(e.inputType==="query_model"){this.createGroup(e,[]);return}e.inputType==="table"&&this.createGroup(e,[])},createVariable(e){const t=this.__generateVariableName(e==null?this.variables:e.children),l={id:K(),type:"variable",name:t,label:t,inputType:"input",required:!1,hidden:!1,defaultValue:"",compiler:"static",remark:"",options:[]};e!=null?e.children.push(l):this.variables.push(l),this.saveVariables(),this.$nextTick(()=>{const h=this.$refs.tree.getNode(l);this.selectVariable(l,h),this.$refs.tree.setCurrentKey(l.id),this.$nextTick(()=>{this.$refs.variableSettingForm.focus()})})},createGroup(e,t){const l=this.__generateGroupName(),h={id:K(),type:"group",name:l,label:l,children:[],defaultValue:t};e==null?this.variables.push(h):(e.children==null&&(e.children=[]),e.children.push(h)),this.currentVariable=h,this.saveVariables()},saveVariables(){this.timeout.save!=null&&clearTimeout(this.timeout.save),this.timeout.save=setTimeout(()=>{this.saveVariablesApi({...this.unique,variables:this.getVariables()}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.timeout.save=null})},300)},fetchVariables(){this.fetchConfigApi({...this.unique}).then(e=>{this.variables=e.variables.map(t=>this.__getInitVariable(t))}).catch(e=>{this.$tip.apiFailed(e)})},getVariables(){return this.variables.filter(t=>t.name.trim().length>0&&t.label.trim().length>0).map(t=>this.__getSaveVariable(t))},deleteVariable(){const e=this.currentVariable.type==="variable"?"变量":"变量组";this.deleteConfirm(`确认删除 ${e} 「${this.currentVariable.label}」?删除后无法恢复!`).then(()=>{if(this.currentRootVariable!==this.currentVariable&&(this.currentRootVariable.inputType==="query_model"||this.currentRootVariable.inputType==="table")&&this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1);for(const h of this.currentRootVariable.children)for(const n of h.defaultValue)for(const a in n){if(a==="origin")continue;h.children.find(d=>d.name===a)==null&&!n.origin.hasOwnProperty(a)&&delete n[a]}this.currentVariable=null,this.saveVariables();return}if(this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1),this.currentVariable=null,this.saveVariables();return}const t=this.variables.findIndex(l=>l.id===this.currentVariable.id);t!==-1&&(this.variables.splice(t,1),this.currentVariable=null,this.saveVariables())}).catch(t=>{if(t!=="cancel")throw new Error(t)})},handleDragStart(e){this.dragData.target=e.data},handleDrop(){this.saveVariables()},allowDrag(){return!0},allowDrop(e,t,l){return e.data.type==="variable"?!(t.data.type==="variable"&&l==="inner"):e.data.type==="group"?t.data.type!=="variable":!1},__getValidOptions(e){return e.filter(t=>t.value.trim().length>0&&t.label.trim().length>0)},__getInitVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children==null?[]:t.children.map(l=>(l.options=l.options==null?[]:l.options,this.__getInitVariable(l))),t):(t.options=t.options==null?[]:t.options,t.options.forEach(l=>{l.settings=l.settings==null?[]:l.settings}),t.inputType==="select"&&(JSON.stringify(t.defaultValue.settings)==="{}"||t.options.forEach(l=>{l.settings=l.settings.map(h=>({...h,value:t.defaultValue.settings[h.name]}))})),t)},__getSaveVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children.map(l=>this.__getSaveVariable(l)),t):t.inputType==="number_input"?(t.defaultValue=parseInt(t.defaultValue),t):t.inputType==="query_model"||t.inputType==="table"?(t.children!=null&&t.children.length>0&&(t.children=t.children.map(l=>(l.children=l.children.map(h=>({...this.__getSaveVariable(h),origin:void 0,table:void 0})),l))),delete t.options,t):t.inputType==="select"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{l.settings=l.settings.filter(h=>h.name.trim()!==""&&h.label.trim()!=="")}),t.options.forEach(l=>{l.settings.forEach(h=>{delete h.value})}),t):t.inputType==="radio"||t.inputType==="checkbox"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{delete l.settings}),t):(delete t.options,t)},__generateVariableName(e){let t;for(;;)if(t=`var${this.varIndex}`,this.varIndex++,e.findIndex(l=>l.type==="variable"&&l.name===t)===-1)return t},__generateGroupName(){let e;for(;;)if(e=`group${this.groupIndex}`,this.groupIndex++,this.variables.findIndex(t=>t.type==="group"&&t.name===e)===-1)return e}},created(){this.fetchVariables()}},ae=e=>(x("data-v-aaadc8ba"),e=e(),j(),e),_l={class:"tree"},bl={class:"variables-wrap"},vl={class:"tools"},gl={class:"title"},yl={key:0,class:"opera"},kl={class:"variable-setting"},Vl={class:"title"},Cl=ae(()=>o("h4",null,"变量设置",-1)),Sl={class:"content-wrap"},Tl={key:1,class:"variable-holder"},Rl=ae(()=>o("h5",null,"变量和变量组设置",-1));function Il(e,t,l,h,n,a){const u=r("el-button"),d=r("el-tree"),f=r("VariableSettingForm"),C=r("VariableGroupSettingForm");return m(),k("div",_l,[o("div",bl,[o("div",vl,[i(u,{icon:"Plus",type:"primary",onClick:t[0]||(t[0]=I=>a.createVariable())},{default:s(()=>[v(b(e.$t("service.settings.variable.addVariable")),1)]),_:1}),i(u,{icon:"Plus",type:"primary",onClick:t[1]||(t[1]=I=>a.createGroup(null,"service"))},{default:s(()=>[v(b(e.$t("service.settings.variable.addGroup")),1)]),_:1})]),i(d,{ref:"tree",class:"variables","expand-on-click-node":!1,"default-expand-all":!0,"highlight-current":!0,data:n.variables,"node-key":"id",onNodeClick:a.selectVariable,draggable:"","allow-drop":a.allowDrop,"allow-drag":a.allowDrag,"empty-text":e.$t("service.settings.variable.noVariables"),onNodeDragStart:a.handleDragStart,onNodeDrop:a.handleDrop},{default:s(({node:I,data:_})=>[o("div",gl,[o("span",null,b(_.label),1),_.type==="group"||_.inputType==="query_model"||_.inputType==="table"?(m(),k("div",yl,[i(u,{class:"button-icon",icon:"Plus",size:"small",onClick:W(T=>a.createChild(_),["stop"])},null,8,["onClick"])])):N("",!0)])]),_:1},8,["data","onNodeClick","allow-drop","allow-drag","empty-text","onNodeDragStart","onNodeDrop"])]),o("div",kl,[o("div",Vl,[Cl,n.currentVariable!=null?(m(),y(u,{key:0,size:"default",type:"danger",link:"",onClick:a.deleteVariable},{default:s(()=>[v("删除变量")]),_:1},8,["onClick"])):N("",!0)]),o("div",Sl,[n.currentVariable!=null?(m(),k(z,{key:0},[n.currentVariable.type==="variable"?(m(),y(f,{key:0,ref:"variableSettingForm",variable:n.currentVariable,"variable-group":n.currentGroup,"root-variable":n.currentRootVariable,onChange:a.saveVariables},null,8,["variable","variable-group","root-variable","onChange"])):N("",!0),n.currentVariable.type==="group"?(m(),y(C,{key:1,variable:n.currentVariable,onChange:a.saveVariables},null,8,["variable","onChange"])):N("",!0)],64)):(m(),k("div",Tl,[Rl,o("p",null,"点击左侧变量来打开变量或变量组设置。如无法获取变量值,请留意"+b(l.plugin==null?"服务":"插件")+"设置中选择的编译器。",1)]))])])])}const Xl=w(fl,[["render",Il],["__scopeId","data-v-aaadc8ba"]]);const wl={name:"SystemVariableTable",data(){return{variableData:{date:[{name:"_yyyy",enRemark:"",zhRemark:"年(固定4位)",demo:"${_yyyy} => 1993"},{name:"_MM",enRemark:"",zhRemark:"月(固定2位)",demo:"${_MM} => 08"},{name:"_dd",enRemark:"",zhRemark:"日前(固定2位)",demo:"${_dd} => 13"},{name:"_hh",enRemark:"",zhRemark:"时(固定2位)",demo:"${_hh} => 00"},{name:"_mm",enRemark:"",zhRemark:"分(固定2位)",demo:"${_mm} => 00"},{name:"_ss",enRemark:"",zhRemark:"秒(固定2位)",demo:"${_ss} => 00"},{name:"_sss",enRemark:"",zhRemark:"毫秒(固定3位)",demo:"${_sss} => 000"}],mysqlTable:[{name:"name",enRemark:"",zhRemark:"原始表名",demo:"${myTable.name} => MY_TABLE"},{name:"camelCaseName",enRemark:"",zhRemark:"表名(驼峰命名法)",demo:"${myTable.camelCaseName} => myTable"},{name:"kebabCaseName",enRemark:"",zhRemark:"表名(中划线命名法)",demo:"${myTable.kebabCaseName} => my-table"},{name:"pascalCaseName",enRemark:"",zhRemark:"表名(帕斯卡命名法)",demo:"${myTable.pascalCaseName} => MyTable"},{name:"underScoreCaseName",enRemark:"",zhRemark:"表名(下划线命名法)",demo:"${myTable.underScoreCaseName} => my_table"},{name:"alias",enRemark:"",zhRemark:"表别名,默认与表名一致",demo:"${myTable.alias} => MY_ALIAS"},{name:"camelCaseAlias",enRemark:"",zhRemark:"表别名(驼峰命名法)",demo:"${myTable.camelCaseAlias} => myAlias"},{name:"kebabCaseAlias",enRemark:"",zhRemark:"表别名(中划线命名法)",demo:"${myTable.kebabCaseAlias} => my-alias"},{name:"pascalCaseAlias",enRemark:"",zhRemark:"表别名(帕斯卡命名法)",demo:"${myTable.pascalCaseAlias} => MyAlias"},{name:"underScoreCaseAlias",enRem