UNPKG

goldpankit

Version:

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

2 lines (1 loc) 11.8 kB
import{_ as C,r as u,o as a,h as _,w as f,a as c,b as h,Q as F,R as x,S as L,T as R,m as B,s as M,i as G,U as O,V as N,W as A,c as p,t as m,F as V,g as $,e as b,j as g,X as U,p as z,l as J}from"./index-6d4e95d5.js";import{V as Q,S as X,F as H,M as K,a as Y,I as Z,b as ee,c as te,i as I,g as ie}from"./ServiceCodeErrorWindow-e7ef5e83.js";import{b as ne}from"./service.version-e71a8ad5.js";import{_ as se}from"./wechat-ae447c56.js";const le={name:"VipExpiredWindow",data(){return{visible:!1,priceTableData:[{dayCount:"90天",price:"299元"},{dayCount:"365天",price:"799元"}]}},methods:{open(){this.visible=!0}}},re={class:"wrap"},ae=c("h2",null,"您的账号已过期,请添加下方微信,我们的客服人员会为您续费会员!",-1),oe=c("div",{class:"wechat-wrap"},[c("img",{src:se}),c("span",null,"小艺")],-1),ce={class:"price-wrap"},ue=c("h4",null,"价格套餐",-1);function pe(e,t,i,n,s,l){const r=u("el-table-column"),d=u("el-table"),v=u("el-dialog");return a(),_(v,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=k=>s.visible=k),class:"vip-expired-window",width:"500px"},{default:f(()=>[c("div",re,[ae,oe,c("div",ce,[ue,h(d,{data:s.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 de=C(le,[["render",pe]]);const he={name:"ServiceInstaller",components:{VariableRemarkIcon:Q,VipExpiredWindow:de,FormItemTip:F,ServiceCodeErrorWindow:X,MergeWindow:x,ProjectSelect:L,DirectorySelect:R,FieldSetting:H,MySqlFieldSelect:K,VariableInput:Y,InstallRadio:Z,InstallInput:ee,InstallCheckbox:te},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:{...B(["userInfo","currentProject","currentProjectDetail","currentDatabase"]),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"]),...O(["getCurrentDatabaseDetail"]),fetchVersion(){ne({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}N({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,A({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=>I(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(I(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(i.value))return this.__tipEmptyVariable(i,t),!1}return!0},__tipEmptyVariable(e,t){t!=null?this.$tip.warning(`请填写「${t}」中「${e.label}」参数`):this.$tip.warning(`请填写「${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??ie(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()}},fe=e=>(z("data-v-674284fe"),e=e(),J(),e),_e={class:"service-installer"},me={key:0,class:"nav"},ge={class:"title"},Ve={key:0,class:"install"},ve=fe(()=>c("p",{class:"install-tip"},"安装提示: 填写以下信息并点击「立即安装」按钮即可安装代码到您项目目录中。",-1)),ye={class:"form-wrap"},be={class:"label-wrap"},ke={class:"label-wrap-left"},we={key:0,class:"label-wrap-right"},$e={key:1,class:"group-vars"},Ie={class:"text-info-1 text-mini"},We={key:0},je={key:1,class:"parameters-holder"};function Ce(e,t,i,n,s,l){const r=u("el-option"),d=u("el-select"),v=u("el-button"),k=u("ProjectSelect"),w=u("FormItemTip"),W=u("el-form-item"),S=u("VariableRemarkIcon"),D=u("ArrowRight"),P=u("el-icon"),j=u("VariableInput"),T=u("el-form"),q=u("ServiceCodeErrorWindow"),E=u("VipExpiredWindow");return a(),p("div",_e,[i.withTitle?(a(),p("div",me,[c("div",ge,[c("h4",null,"@"+m(i.space)+"/"+m(i.service)+" · "+m(e.$t("service.install2"))+" · ",1),h(d,{size:"default",modelValue:s.selectedVersion,"onUpdate:modelValue":t[0]||(t[0]=o=>s.selectedVersion=o)},{default:f(()=>[(a(!0),p(V,null,$(i.versions,o=>(a(),_(r,{key:o,value:o},{default:f(()=>[b(m(o),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),i.withInstallButton?(a(),p("div",Ve,[e.userInfo==null?(a(),_(v,{key:0,type:"important",onClick:t[1]||(t[1]=o=>e.$router.push({name:"SignIn"}))},{default:f(()=>[b("登录后可安装服务")]),_:1})):(a(),_(v,{key:1,type:"important",onClick:l.install,disabled:s.isWorking.install},{default:f(()=>[b(m(s.isWorking.install?e.$t("service.installing"):e.$t("service.install")),1)]),_:1},8,["onClick","disabled"]))])):g("",!0)])):g("",!0),c("div",{class:"content-wrap",style:U(l.contentWrapStyle)},[i.withProject||l.serviceVariables.length>0?(a(),p(V,{key:0},[ve,c("div",ye,[h(T,null,{default:f(()=>[i.withProject?(a(),_(W,{key:0,label:"项目",required:"",class:"form-item-project"},{default:f(()=>[h(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(),_(w,{key:0,content:"服务安装后的代码将存放至指定的项目目录中,请先选择或创建一个项目!"})):(a(),_(w,{key:1,content:`服务安装后代码将写入<em>${e.currentProjectDetail.codespace}</em>目录。`},null,8,["content"]))]),_:1})):g("",!0),(a(!0),p(V,null,$(l.serviceVariables,o=>(a(),p(V,null,[o.hidden?g("",!0):(a(),_(W,{key:o.name,label:o.label,required:o.required},{label:f(()=>[c("div",be,[c("div",ke,[c("label",null,m(o.label),1),h(S,{variable:o},null,8,["variable"])]),o.type!=="variable"?(a(),p("div",we,[h(P,null,{default:f(()=>[h(D)]),_:1})])):g("",!0)])]),default:f(()=>[o.type==="variable"?(a(),_(j,{key:0,variable:o},null,8,["variable"])):o.type==="group"?(a(),p("ul",$e,[(a(!0),p(V,null,$(o.children,y=>(a(),p("li",{key:`${o.name}_${y.name}`},[c("label",Ie,[y.required?(a(),p("em",We,"*")):g("",!0),b(m(y.label),1)]),h(j,{variable:y},null,8,["variable"])]))),128))])):g("",!0),o.inputType==="datasource"&&e.getCurrentDatabaseDetail()!=null?(a(),_(w,{key:2,content:`路径:${e.getCurrentDatabaseDetail().host}:${e.getCurrentDatabaseDetail().port}/${e.getCurrentDatabaseDetail().schema}`},null,8,["content"])):g("",!0)]),_:2},1032,["label","required"]))],64))),256))]),_:1})])],64)):(a(),p("div",je,[c("p",null,m(e.$t("service.withoutParametersTip")),1)]))],4),h(q,{ref:"serviceCodeErrorWindow"},null,512),h(E,{ref:"vipExpiredWindow"},null,512)])}const qe=C(he,[["render",Ce],["__scopeId","data-v-674284fe"]]);export{qe as S};