UNPKG

goldpankit

Version:

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

2 lines (1 loc) 11.2 kB
import{_ as S,r as c,o as a,g as m,w as h,a as u,b as f,N as E,P as F,Q as L,R as B,m as x,n as M,h as R,S as G,T as N,c as p,t as _,F as V,f as w,e as v,i as g,U as O}from"./index-1a25b643.js";import{S as A,F as U,M as z,V as J,I as Q,a as H,b as K,i as $,g as X}from"./ServiceCodeErrorWindow-686bf770.js";import{b as Y}from"./service.version-058d72b2.js";import{_ as Z}from"./wechat-ae447c56.js";const ee={name:"VipExpiredWindow",data(){return{visible:!1,priceTableData:[{dayCount:"90天",price:"299元"},{dayCount:"365天",price:"799元"}]}},methods:{open(){this.visible=!0}}},te={class:"wrap"},ie=u("h2",null,"您的账号已过期,请添加下方微信,我们的客服人员会为您续费会员!",-1),ne=u("div",{class:"wechat-wrap"},[u("img",{src:Z}),u("span",null,"小艺")],-1),se={class:"price-wrap"},le=u("h4",null,"价格套餐",-1);function re(e,t,i,n,s,l){const r=c("el-table-column"),d=c("el-table"),y=c("el-dialog");return a(),m(y,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=k=>s.visible=k),"custom-class":"vip-expired-window",width:"500px"},{default:h(()=>[u("div",te,[ie,ne,u("div",se,[le,f(d,{data:s.priceTableData},{default:h(()=>[f(r,{align:"center",prop:"dayCount",label:"时长"}),f(r,{align:"center",prop:"price","class-name":"price",label:"价格"})]),_:1},8,["data"])])])]),_:1},8,["modelValue"])}const ae=S(ee,[["render",re]]);const oe={name:"ServiceInstaller",components:{VipExpiredWindow:ae,FormItemTip:E,ServiceCodeErrorWindow:A,MergeWindow:F,ProjectSelect:L,DirectorySelect:B,FieldSetting:U,MySqlFieldSelect:z,VariableInput:J,InstallRadio:Q,InstallInput:H,InstallCheckbox:K},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.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"]),...R(["refreshBalance"]),fetchVersion(){Y({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(){this.versionData!=null&&(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}G({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}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 n of i.children){const s=n.value;for(const l of n.children){if(!l.required)continue;const r=s.find(d=>$(d[l.name]));if(r!=null)return this.$tip.warning(this.$t("service.fieldMissingValueTip",{fieldGroupLabel:n.label,emptyFieldName:r.name,fieldVariableLabel:l.label})),!1}}continue}if(i.inputType==="select"){const n=i.value;if(i.required&&n.value==null)return this.__tipEmptyVariable(i,t),!1;if(n.value!=null){const s=i.options.find(l=>l.value===n.value);if(s.settings.length>0){for(const l of s.settings)if($(n.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(s=>s.value===t.value.value);if(i==null)return t;const n={};for(const s of i.settings)n[s.name]=s.value;t.value.settings=n}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 n=this.projectConfig.plugins||this.projectConfig.services;if(n!=null){const s=n[this.plugin];if(s!=null){const l=s.variables.findLast(r=>r.name===e.name);l!=null&&(t=l.value)}}if(t==null){const s=this.projectConfig.service||this.projectConfig.main;if(s!=null){let l=null;for(const d in s){l=d;break}const r=s[l].variables[e.name];t=r,r!=null&&r.constructor!==e.defaultValue.constructor&&(t=null)}}}else{const n=this.projectConfig.service||this.projectConfig.main;if(n!=null){const s=n[this.service];if(s!=null){const l=s.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 n in t.settings){const s=e.children.find(r=>r.name===n);if(s==null)continue;let l=t.settings[n];for(const r of s.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`];s.value=t.settings[n]}return e.value=t.value,e}return e.type==="group"?(e.children.forEach(n=>this.__initVariableValue(n,t[n.name],!1)),e):(e.value=t,e)}if(t=e.defaultValue,t=t??X(e.inputType),e.inputType==="table"||e.inputType==="query_model"){if(e.children!=null)for(const n of e.children)n.value=n.defaultValue;return e.value=t,e}return e.type==="group"?(e.children!=null&&e.children.forEach(n=>{n.value=n.defaultValue}),e):(e.value=t,e)}},created(){this.fetchVersion()}},ce={class:"service-installer"},ue={key:0,class:"nav"},pe={class:"title"},de={key:0,class:"install"},he={class:"install-tip"},fe={class:"form-wrap"},_e={key:1,class:"label-wrap"},me={key:1,class:"group-vars"},ge={class:"text-info-1 text-mini"},Ve={key:0},ve={key:1,class:"parameters-holder"};function ye(e,t,i,n,s,l){const r=c("el-option"),d=c("el-select"),y=c("el-button"),k=c("ProjectSelect"),j=c("FormItemTip"),W=c("el-form-item"),I=c("ArrowRight"),C=c("el-icon"),D=c("VariableInput"),T=c("el-form"),P=c("ServiceCodeErrorWindow"),q=c("VipExpiredWindow");return a(),p("div",ce,[i.withTitle?(a(),p("div",ue,[u("div",pe,[u("h4",null,"@"+_(i.space)+"/"+_(i.service)+" · "+_(e.$t("service.install2"))+" · ",1),f(d,{modelValue:s.selectedVersion,"onUpdate:modelValue":t[0]||(t[0]=o=>s.selectedVersion=o)},{default:h(()=>[(a(!0),p(V,null,w(i.versions,o=>(a(),m(r,{key:o,value:o},{default:h(()=>[v(_(o),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),i.withInstallButton?(a(),p("div",de,[e.userInfo==null?(a(),m(y,{key:0,type:"important",onClick:t[1]||(t[1]=o=>e.$router.push({name:"SignIn"}))},{default:h(()=>[v("登录后可安装服务")]),_:1})):(a(),m(y,{key:1,type:"important",onClick:l.install,disabled:s.isWorking.install},{default:h(()=>[v(_(s.isWorking.install?e.$t("service.installing"):e.$t("service.install")),1)]),_:1},8,["onClick","disabled"]))])):g("",!0)])):g("",!0),u("div",{class:"content-wrap",style:O(l.contentWrapStyle)},[i.withProject||l.serviceVariables.length>0?(a(),p(V,{key:0},[u("p",he,_(e.$t("service.withParametersTip")),1),u("div",fe,[f(T,null,{default:h(()=>[i.withProject?(a(),m(W,{key:0,label:e.$t("project.project"),required:"",class:"form-item-project"},{default:h(()=>[f(k,{"model-value":e.currentProject,"with-block":!0,"with-prefix":!1,onChange:t[2]||(t[2]=o=>e.$emit("change-project",o))},null,8,["model-value"]),e.currentProjectDetail!=null?(a(),m(j,{key:0,content:`服务安装后代码将写入<em>${e.currentProjectDetail.codespace}</em>目录。`},null,8,["content"])):g("",!0)]),_:1},8,["label"])):g("",!0),(a(!0),p(V,null,w(l.serviceVariables,o=>(a(),p(V,null,[o.hidden?g("",!0):(a(),m(W,{key:o.name,label:o.label,required:o.required},{label:h(()=>[o.type==="variable"?(a(),p(V,{key:0},[v(_(o.label),1)],64)):(a(),p("div",_e,[u("span",null,_(o.label),1),f(C,null,{default:h(()=>[f(I)]),_:1})]))]),default:h(()=>[o.type==="variable"?(a(),m(D,{key:0,variable:o},null,8,["variable"])):o.type==="group"?(a(),p("ul",me,[(a(!0),p(V,null,w(o.children,b=>(a(),p("li",{key:`${o.name}_${b.name}`},[u("label",ge,[b.required?(a(),p("em",Ve,"*")):g("",!0),v(_(b.label),1)]),f(D,{variable:b},null,8,["variable"])]))),128))])):g("",!0),o.inputType==="datasource"&&e.currentDatabaseDetail!=null?(a(),m(j,{key:2,content:`基础信息:${e.currentDatabaseDetail.host}:${e.currentDatabaseDetail.port}/${e.currentDatabaseDetail.schema}`},null,8,["content"])):g("",!0)]),_:2},1032,["label","required"]))],64))),256))]),_:1})])],64)):(a(),p("div",ve,[u("p",null,_(e.$t("service.withoutParametersTip")),1)]))],4),f(P,{ref:"serviceCodeErrorWindow"},null,512),f(q,{ref:"vipExpiredWindow"},null,512)])}const je=S(oe,[["render",ye],["__scopeId","data-v-4ac58b3f"]]);export{je as S};