UNPKG

goldpankit

Version:

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

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