UNPKG

goldpankit

Version:

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

2 lines (1 loc) 13.2 kB
import{_ as I,r as c,o,h as g,w as f,a as u,b as d,P as x,Q as R,R as B,S as O,m as L,q as N,i as G,T as M,U,V as A,c as h,t as v,F as k,g as S,e as C,j as _,W as J,p as z,l as Q}from"./index-ae815648.js";import{P as H,V as K,S as X,F as Y,M as Z,a as ee,I as te,b as ie,c as ne,i as j,g as se}from"./PluginSelector-38ccc852.js";import{b as le}from"./service.version-35b857d8.js";import{_ as re}from"./wechat-ae447c56.js";import{b as ae}from"./service-39ac4673.js";const oe={name:"VipExpiredWindow",data(){return{visible:!1,priceTableData:[{dayCount:"90天",price:"299元"},{dayCount:"365天",price:"799元"}]}},methods:{open(){this.visible=!0}}},ce={class:"wrap"},ue=u("h2",null,"您的账号已过期,请添加下方微信,我们的客服人员会为您续费会员!",-1),pe=u("div",{class:"wechat-wrap"},[u("img",{src:re}),u("span",null,"小艺")],-1),de={class:"price-wrap"},he=u("h4",null,"价格套餐",-1);function fe(e,t,n,s,i,l){const r=c("el-table-column"),p=c("el-table"),b=c("el-dialog");return o(),g(b,{modelValue:i.visible,"onUpdate:modelValue":t[0]||(t[0]=m=>i.visible=m),class:"vip-expired-window",width:"500px"},{default:f(()=>[u("div",ce,[ue,pe,u("div",de,[he,d(p,{data:i.priceTableData},{default:f(()=>[d(r,{align:"center",prop:"dayCount",label:"时长"}),d(r,{align:"center",prop:"price","class-name":"price",label:"价格"})]),_:1},8,["data"])])])]),_:1},8,["modelValue"])}const _e=I(oe,[["render",fe]]);const ge={name:"ServiceInstaller",components:{PluginSelector:H,VariableRemarkIcon:K,VipExpiredWindow:_e,FormItemTip:x,ServiceCodeErrorWindow:X,MergeWindow:R,ProjectSelect:B,DirectorySelect:O,FieldSetting:Y,MySqlFieldSelect:Z,VariableInput:ee,InstallRadio:te,InstallInput:ie,InstallCheckbox:ne},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:[],selectedPlugins:[],selectedVersion:null}},computed:{...L(["userInfo","currentProject","currentProjectDetail","currentDatabase"]),isPlugin(){return this.plugin!=null},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]},majorVersion(){return this.selectedVersion.trim()===""?"":this.selectedVersion.split(".")[0]}},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(),this.fetchPresetPlugins()},selectedVersion(){this.fetchPresetPlugins()}},methods:{...N(["setInstallData"]),...G(["refreshBalance"]),...M(["getCurrentDatabaseDetail"]),fetchPresetPlugins(){if(!this.isPlugin){if(this.currentProject==null){this.selectedPlugins=[];return}if(this.projectConfig!=null&&this.projectConfig.plugins!=null){const e=[];for(const t in this.projectConfig.plugins)this.projectConfig.plugins[t].variables.find(i=>i.inputType==="table"||i.inputType==="query_model")==null&&e.push({name:t});this.selectedPlugins=e;return}ae({space:this.space,service:this.service,version:this.version}).then(e=>{this.selectedPlugins=e}).catch(e=>{this.$tip.apiFailed(e)})}},fetchVersion(){le({space:this.space,service:this.service,plugin:this.plugin,version:this.selectedVersion}).then(e=>{this.versionData=e,this.initVariables(),this.fetchPresetPlugins()}).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}U({projectId:this.currentProject,database:this.currentDatabase,space:this.space,service:this.service,plugin:this.plugin,version:this.selectedVersion,plugins:this.selectedPlugins,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 n of e){if(n.inputType==="query_model"||n.inputType==="table"){if(n.required&&(n.value==null||n.value===""))return this.__tipEmptyVariable(n,t),!1;if(n.children==null||n.children.length===0)continue;for(const s of n.children){const i=s.value;for(const l of s.children){if(!l.required)continue;if(l.inputType==="select"){let p=null,b=null;for(const m of i){const V=l.options.find(y=>y.value===m[l.name].value);if(V==null)return this.$tip.warning(`在「${s.label}」中,「${m.name}」字段缺少「${l.label}」`),!1;const P=V.settings;for(const y of P){if(!y.required)continue;const $=m[l.name].settings[y.name];j($)&&(p=y,b=m)}}if(p!=null)return this.$tip.warning(`在「${s.label}」中,${b.name}」字段缺少「${p.label}」的设定`),!1}const r=i.find(p=>j(p[l.name]));if(r!=null)return this.$tip.warning(`在「${s.label}」中,「${r.name}」字段缺少「${l.label}」`),!1}}continue}if(n.inputType==="select"){const s=n.value;if(n.required&&s.value==null)return this.__tipEmptyVariable(n,t),!1;if(s.value!=null){const i=n.options.find(l=>l.value===s.value);if(i.settings.length>0){for(const l of i.settings)if(j(s.settings[l.name]))return this.$tip.warning(`「${n.label}」缺少「${l.label}」设定`),!1}}continue}if(n.type==="group"){if(!this.__checkVariables(n.children,n.label))return!1;continue}if(n.required&&j(n.value))return this.__tipEmptyVariable(n,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 n=t.options.find(i=>i.value===t.value.value);if(n==null)return t;const s={};for(const i of n.settings)s[i.name]=i.value;t.value.settings=s}return t.type==="group"&&(t.children=this.__getInstallVariables(t.children)),t})},__initVariableValue(e,t,n=!0){if(t==null&&n&&this.projectConfig!=null)if(this.isPlugin){const s=this.projectConfig.plugins||this.projectConfig.services;if(s!=null){const i=s[this.plugin];if(i!=null){const l=i.variables.findLast(r=>r.name===e.name);l!=null&&l.value!=null&&(t=JSON.parse(JSON.stringify(l.value)))}}if(t==null){const i=this.projectConfig.service||this.projectConfig.main;if(i!=null){let l=null;for(const p in i){l=p;break}const r=i[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 i=s[this.service];if(i!=null){const l=i.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 i=e.children.find(r=>r.name===s);if(i==null)continue;let l=t.settings[s];for(const r of i.children)if(r.inputType==="select")for(const p of l)p[r.name]={value:p[r.name],settings:p[`${r.name}Settings`]},delete p[`${r.name}Settings`];i.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??se(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()}},me=e=>(z("data-v-dfc18ab4"),e=e(),Q(),e),ve={class:"service-installer"},Ve={key:0,class:"nav"},ye={class:"title"},be={key:0,class:"install"},Pe=me(()=>u("p",{class:"install-tip"},"安装提示: 填写以下信息并点击「立即安装」按钮即可安装代码到您项目目录中。",-1)),ke={class:"form-wrap"},we={class:"label-wrap"},je={class:"label-wrap-left"},$e={key:0,class:"label-wrap-right"},Se={key:1,class:"group-vars"},Ce={class:"text-info-1 text-mini"},We={key:0},Ie={key:1,class:"parameters-holder"};function De(e,t,n,s,i,l){const r=c("el-option"),p=c("el-select"),b=c("el-button"),m=c("ProjectSelect"),V=c("FormItemTip"),P=c("el-form-item"),y=c("VariableRemarkIcon"),$=c("ArrowRight"),D=c("el-icon"),W=c("VariableInput"),q=c("PluginSelector"),T=c("el-form"),E=c("ServiceCodeErrorWindow"),F=c("VipExpiredWindow");return o(),h("div",ve,[n.withTitle?(o(),h("div",Ve,[u("div",ye,[u("h4",null,"@"+v(n.space)+"/"+v(n.service)+" · "+v(e.$t("service.install2"))+" · ",1),d(p,{size:"default",modelValue:i.selectedVersion,"onUpdate:modelValue":t[0]||(t[0]=a=>i.selectedVersion=a)},{default:f(()=>[(o(!0),h(k,null,S(n.versions,a=>(o(),g(r,{key:a,value:a},{default:f(()=>[C(v(a),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),n.withInstallButton?(o(),h("div",be,[d(b,{type:"important",onClick:l.install,disabled:i.isWorking.install},{default:f(()=>[C(v(i.isWorking.install?e.$t("service.installing"):e.$t("service.install")),1)]),_:1},8,["onClick","disabled"])])):_("",!0)])):_("",!0),u("div",{class:"content-wrap",style:J(l.contentWrapStyle)},[n.withProject||i.variables.length>0?(o(),h(k,{key:0},[Pe,u("div",ke,[d(T,null,{default:f(()=>[n.withProject?(o(),g(P,{key:0,label:"项目",required:"",class:"form-item-project"},{default:f(()=>[d(m,{"model-value":e.currentProject,"with-block":!0,"with-prefix":!1,onChange:t[1]||(t[1]=a=>e.$emit("change-project",a))},null,8,["model-value"]),e.currentProjectDetail==null?(o(),g(V,{key:0,content:"服务安装后的代码将存放至指定的项目目录中,请先选择或创建一个项目!"})):(o(),g(V,{key:1,content:`服务安装后代码将写入<em>${e.currentProjectDetail.codespace}</em>目录。`},null,8,["content"]))]),_:1})):_("",!0),(o(!0),h(k,null,S(i.variables,a=>(o(),h(k,null,[a.hidden?_("",!0):(o(),g(P,{key:a.name,label:a.label,required:a.required},{label:f(()=>[u("div",we,[u("div",je,[u("label",null,v(a.label),1),d(y,{variable:a},null,8,["variable"])]),a.type!=="variable"?(o(),h("div",$e,[d(D,null,{default:f(()=>[d($)]),_:1})])):_("",!0)])]),default:f(()=>[a.type==="variable"?(o(),g(W,{key:0,variable:a},null,8,["variable"])):a.type==="group"?(o(),h("ul",Se,[(o(!0),h(k,null,S(a.children,w=>(o(),h("li",{key:`${a.name}_${w.name}`},[u("label",Ce,[w.required?(o(),h("em",We,"*")):_("",!0),C(v(w.label),1)]),d(W,{variable:w},null,8,["variable"])]))),128))])):_("",!0),a.inputType==="datasource"&&e.getCurrentDatabaseDetail()!=null?(o(),g(V,{key:2,content:`路径:${e.getCurrentDatabaseDetail().host}:${e.getCurrentDatabaseDetail().port}/${e.getCurrentDatabaseDetail().schema}`},null,8,["content"])):_("",!0)]),_:2},1032,["label","required"]))],64))),256)),l.isPlugin?_("",!0):(o(),g(P,{key:1,label:"选择插件"},{default:f(()=>[d(q,{modelValue:i.selectedPlugins,"onUpdate:modelValue":t[2]||(t[2]=a=>i.selectedPlugins=a),space:n.space,service:n.service,"major-version":l.majorVersion},null,8,["modelValue","space","service","major-version"]),d(V,{content:"插件是一个具体功能或技术集成的代码,选择对应的插件后,将自动产生对应代码!"})]),_:1}))]),_:1})])],64)):(o(),h("div",Ie,[u("p",null,v(e.$t("service.withoutParametersTip")),1)]))],4),d(E,{ref:"serviceCodeErrorWindow"},null,512),d(F,{ref:"vipExpiredWindow"},null,512)])}const Re=I(ge,[["render",De],["__scopeId","data-v-dfc18ab4"]]);export{Re as S};