goldpankit
Version:
GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。
2 lines (1 loc) • 11.6 kB
JavaScript
import{_ as D,r as u,o,g,w as f,a as c,b as h,Q as F,R as L,S as R,T as B,m as x,q as M,h as G,U as O,V as N,c as p,t as _,F as V,f as w,e as y,i as m,W as A}from"./index-dd2ed0b0.js";import{V as U,S as z,F as J,M as Q,a as H,I as K,b as X,c as Y,i as $,g as Z}from"./ServiceCodeErrorWindow-12a16ff7.js";import{b as ee}from"./service.version-a6e086d1.js";import{_ as te}from"./wechat-ae447c56.js";const ie={name:"VipExpiredWindow",data(){return{visible:!1,priceTableData:[{dayCount:"90天",price:"299元"},{dayCount:"365天",price:"799元"}]}},methods:{open(){this.visible=!0}}},se={class:"wrap"},ne=c("h2",null,"您的账号已过期,请添加下方微信,我们的客服人员会为您续费会员!",-1),le=c("div",{class:"wechat-wrap"},[c("img",{src:te}),c("span",null,"小艺")],-1),re={class:"price-wrap"},ae=c("h4",null,"价格套餐",-1);function oe(e,t,i,s,n,l){const r=u("el-table-column"),d=u("el-table"),v=u("el-dialog");return o(),g(v,{modelValue:n.visible,"onUpdate:modelValue":t[0]||(t[0]=k=>n.visible=k),"custom-class":"vip-expired-window",width:"500px"},{default:f(()=>[c("div",se,[ne,le,c("div",re,[ae,h(d,{data:n.priceTableData},{default:f(()=>[h(r,{align:"center",prop:"dayCount",label:"时长"}),h(r,{align:"center",prop:"price","class-name":"price",label:"价格"})]),_:1},8,["data"])])])]),_:1},8,["modelValue"])}const ce=D(ie,[["render",oe]]);const ue={name:"ServiceInstaller",components:{VariableRemarkIcon:U,VipExpiredWindow:ce,FormItemTip:F,ServiceCodeErrorWindow:z,MergeWindow:L,ProjectSelect:R,DirectorySelect:B,FieldSetting:J,MySqlFieldSelect:Q,VariableInput:H,InstallRadio:K,InstallInput:X,InstallCheckbox:Y},props:{installing:{},uninstalling:{},space:{required:!0},service:{required:!0},plugin:{required:!1},servicePrice:{required:!0},serviceLease:{required:!1},version:{required:!0},versions:{required:!1,default(){return[]}},withProject:{default:!0},projectConfig:{},withTitle:{default:!1},withInstallButton:{default:!1}},data(){return{isWorking:{install:!1,uninstall:!1},versionData:null,variables:[],selectedVersion:null}},computed:{...x(["userInfo","currentProject","currentProjectDetail","currentDatabase","currentDatabaseDetail"]),isPlugin(){return this.plugin!=null},serviceVariables(){return this.variables},contentWrapStyle(){return this.withTitle?"border-top: 3px; margin-top: 20px;":"padding-top: 0; border-top: 0;margin-top: 0;"},unique(){return[this.space,this.service,this.plugin,this.selectedVersion]}},watch:{version:{immediate:!0,handler(e){this.selectedVersion=e}},unique(){this.fetchVersion()},"isWorking.install":function(){this.$emit("update:installing",this.isWorking.install)},"isWorking.uninstall":function(){this.$emit("update:uninstalling",this.isWorking.uninstall)},projectConfig(){this.initVariables()},plugin(){this.initVariables()}},methods:{...M(["setInstallData"]),...G(["refreshBalance"]),fetchVersion(){ee({space:this.space,service:this.service,plugin:this.plugin,version:this.selectedVersion}).then(e=>{this.versionData=e,this.initVariables()}).catch(e=>{this.$tip.apiFailed(e)})},install(){if(this.serviceLease!=null){this.__install();return}if(this.servicePrice<50){this.__install();return}this.installConfirm(this.servicePrice).then(()=>{this.__install()}).catch(()=>{})},initVariables(){if(this.versionData==null){this.variables=[];return}this.variables=JSON.parse(this.versionData.variables).map(e=>this.__initVariableValue(e,null))},__install(){if(this.isWorking.install)return;if(this.isWorking.install=!0,this.currentProject==null||this.currentProject===""){this.$tip.warning(this.$t("service.selectProject")),this.isWorking.install=!1;return}const e=this.__getInstallVariables(this.variables);if(!this.__checkVariables(e)){this.isWorking.install=!1;return}O({projectId:this.currentProject,database:this.currentDatabase,space:this.space,service:this.service,plugin:this.plugin,version:this.selectedVersion,variables:e}).then(t=>{this.isWorking.install=!1,this.$tip.success(this.$t("service.installSuccessfully")),this.setInstallData(t),this.refreshBalance(),this.$emit("installed")}).catch(t=>{if(t.code===6e3){this.$refs.serviceCodeErrorWindow.open(t.errorData);return}if(t.code===6200){this.$refs.vipExpiredWindow.open();return}if(t.code===5111){this.error(`您当前项目服务版本过低,当前插件至少需要将项目服务升级到v${t.errorData}才可安装!`);return}this.$tip.apiFailed(t)}).finally(()=>{this.isWorking.install=!1})},uninstall(){if(this.serviceLease!=null){this.__uninstall();return}if(this.servicePrice<50){this.__uninstall();return}this.uninstallConfirm().then(()=>{this.__uninstall()}).catch(()=>{})},__uninstall(){this.isWorking.uninstall||(this.isWorking.uninstall=!0,N({projectId:this.currentProject,database:this.currentDatabase,space:this.space,service:this.service,plugin:this.plugin,version:this.selectedVersion,variables:this.__getInstallVariables(this.variables)}).then(e=>{this.isWorking.uninstall=!1,this.$tip.success(this.$t("service.uninstallSuccessfully")),this.setInstallData(e),this.$emit("uninstalled")}).catch(e=>{if(e.code===6e3){this.$refs.serviceCodeErrorWindow.open(e.errorData);return}this.$tip.apiFailed(e)}).finally(()=>{this.isWorking.uninstall=!1}))},__checkVariables(e,t){for(const i of e){if(i.inputType==="query_model"||i.inputType==="table"){if(i.required&&(i.value==null||i.value===""))return this.__tipEmptyVariable(i,t),!1;if(i.children==null||i.children.length===0)continue;for(const s of i.children){const n=s.value;for(const l of s.children){if(!l.required)continue;const r=n.find(d=>$(d[l.name]));if(r!=null)return this.$tip.warning(this.$t("service.fieldMissingValueTip",{fieldGroupLabel:s.label,emptyFieldName:r.name,fieldVariableLabel:l.label})),!1}}continue}if(i.inputType==="select"){const s=i.value;if(i.required&&s.value==null)return this.__tipEmptyVariable(i,t),!1;if(s.value!=null){const n=i.options.find(l=>l.value===s.value);if(n.settings.length>0){for(const l of n.settings)if($(s.settings[l.name]))return this.$tip.warning(this.$t("service.variableMissingSettingTip",{variable:i.label,settingLabel:l.label})),!1}}continue}if(i.type==="group"){if(!this.__checkVariables(i.children,i.label))return!1;continue}if(i.required&&$(i.value))return this.__tipEmptyVariable(i,t),!1}return!0},__tipEmptyVariable(e,t){t!=null?this.$tip.warning(this.$t("service.missingGroupVariableValueTip",{variable:e.label,groupName:t})):this.$tip.warning(this.$t("service.missingVariableValueTip",{variable:e.label}))},__getInstallVariables(e){return e.map(t=>{if(t.inputType==="select"){const i=t.options.find(n=>n.value===t.value.value);if(i==null)return t;const s={};for(const n of i.settings)s[n.name]=n.value;t.value.settings=s}return t.type==="group"&&(t.children=this.__getInstallVariables(t.children)),t})},__initVariableValue(e,t,i=!0){if(t==null&&i&&this.projectConfig!=null)if(this.isPlugin){const s=this.projectConfig.plugins||this.projectConfig.services;if(s!=null){const n=s[this.plugin];if(n!=null){const l=n.variables.findLast(r=>r.name===e.name);l!=null&&(t=l.value)}}if(t==null){const n=this.projectConfig.service||this.projectConfig.main;if(n!=null){let l=null;for(const d in n){l=d;break}const r=n[l].variables[e.name];t=r,r!=null&&r.constructor!==e.defaultValue.constructor&&(t=null)}}}else{const s=this.projectConfig.service||this.projectConfig.main;if(s!=null){const n=s[this.service];if(n!=null){const l=n.variables.findLast(r=>r.name===e.name);l!=null&&(t=l.value)}}}if(t!=null){if(e.inputType==="table"||e.inputType==="query_model"){for(const s in t.settings){const n=e.children.find(r=>r.name===s);if(n==null)continue;let l=t.settings[s];for(const r of n.children)if(r.inputType==="select")for(const d of l)d[r.name]={value:d[r.name],settings:d[`${r.name}Settings`]},delete d[`${r.name}Settings`];n.value=t.settings[s]}return e.value=t.value,e}return e.type==="group"?(e.children.forEach(s=>this.__initVariableValue(s,t[s.name],!1)),e):(e.value=t,e)}if(t=e.defaultValue,t=t??Z(e.inputType),e.inputType==="table"||e.inputType==="query_model"){if(e.children!=null)for(const s of e.children)s.value=s.defaultValue;return e.value=t,e}return e.type==="group"?(e.children!=null&&e.children.forEach(s=>{s.value=s.defaultValue}),e):(e.value=t,e)}},created(){this.fetchVersion()}},pe={class:"service-installer"},de={key:0,class:"nav"},he={class:"title"},fe={key:0,class:"install"},_e={class:"install-tip"},me={class:"form-wrap"},ge={class:"label-wrap"},Ve={class:"label-wrap-left"},ve={key:0,class:"label-wrap-right"},be={key:1,class:"group-vars"},ye={class:"text-info-1 text-mini"},ke={key:0},we={key:1,class:"parameters-holder"};function $e(e,t,i,s,n,l){const r=u("el-option"),d=u("el-select"),v=u("el-button"),k=u("ProjectSelect"),j=u("FormItemTip"),W=u("el-form-item"),S=u("VariableRemarkIcon"),C=u("ArrowRight"),T=u("el-icon"),I=u("VariableInput"),P=u("el-form"),q=u("ServiceCodeErrorWindow"),E=u("VipExpiredWindow");return o(),p("div",pe,[i.withTitle?(o(),p("div",de,[c("div",he,[c("h4",null,"@"+_(i.space)+"/"+_(i.service)+" · "+_(e.$t("service.install2"))+" · ",1),h(d,{modelValue:n.selectedVersion,"onUpdate:modelValue":t[0]||(t[0]=a=>n.selectedVersion=a)},{default:f(()=>[(o(!0),p(V,null,w(i.versions,a=>(o(),g(r,{key:a,value:a},{default:f(()=>[y(_(a),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),i.withInstallButton?(o(),p("div",fe,[e.userInfo==null?(o(),g(v,{key:0,type:"important",onClick:t[1]||(t[1]=a=>e.$router.push({name:"SignIn"}))},{default:f(()=>[y("登录后可安装服务")]),_:1})):(o(),g(v,{key:1,type:"important",onClick:l.install,disabled:n.isWorking.install},{default:f(()=>[y(_(n.isWorking.install?e.$t("service.installing"):e.$t("service.install")),1)]),_:1},8,["onClick","disabled"]))])):m("",!0)])):m("",!0),c("div",{class:"content-wrap",style:A(l.contentWrapStyle)},[i.withProject||l.serviceVariables.length>0?(o(),p(V,{key:0},[c("p",_e,_(e.$t("service.withParametersTip")),1),c("div",me,[h(P,null,{default:f(()=>[i.withProject?(o(),g(W,{key:0,label:e.$t("project.project"),required:"",class:"form-item-project"},{default:f(()=>[h(k,{"model-value":e.currentProject,"with-block":!0,"with-prefix":!1,onChange:t[2]||(t[2]=a=>e.$emit("change-project",a))},null,8,["model-value"]),e.currentProjectDetail!=null?(o(),g(j,{key:0,content:`服务安装后代码将写入<em>${e.currentProjectDetail.codespace}</em>目录。`},null,8,["content"])):m("",!0)]),_:1},8,["label"])):m("",!0),(o(!0),p(V,null,w(l.serviceVariables,a=>(o(),p(V,null,[a.hidden?m("",!0):(o(),g(W,{key:a.name,label:a.label,required:a.required},{label:f(()=>[c("div",ge,[c("div",Ve,[c("label",null,_(a.label),1),h(S,{variable:a},null,8,["variable"])]),a.type!=="variable"?(o(),p("div",ve,[h(T,null,{default:f(()=>[h(C)]),_:1})])):m("",!0)])]),default:f(()=>[a.type==="variable"?(o(),g(I,{key:0,variable:a},null,8,["variable"])):a.type==="group"?(o(),p("ul",be,[(o(!0),p(V,null,w(a.children,b=>(o(),p("li",{key:`${a.name}_${b.name}`},[c("label",ye,[b.required?(o(),p("em",ke,"*")):m("",!0),y(_(b.label),1)]),h(I,{variable:b},null,8,["variable"])]))),128))])):m("",!0),a.inputType==="datasource"&&e.currentDatabaseDetail!=null?(o(),g(j,{key:2,content:`基础信息:${e.currentDatabaseDetail.host}:${e.currentDatabaseDetail.port}/${e.currentDatabaseDetail.schema}`},null,8,["content"])):m("",!0)]),_:2},1032,["label","required"]))],64))),256))]),_:1})])],64)):(o(),p("div",we,[c("p",null,_(e.$t("service.withoutParametersTip")),1)]))],4),h(q,{ref:"serviceCodeErrorWindow"},null,512),h(E,{ref:"vipExpiredWindow"},null,512)])}const Se=D(ue,[["render",$e],["__scopeId","data-v-6d9b9d18"]]);export{Se as S};