goldpankit
Version:
GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。
2 lines (1 loc) • 12.1 kB
JavaScript
import{_ as D,r as p,o as a,h as _,w as f,a as c,b as h,Q as F,R as x,S as R,T as B,m as O,s as L,i as N,U as G,V as M,W as A,c as d,t as g,F as k,g as j,e as I,j as y,X as J,p as U,l as z}from"./index-8602688b.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 S,g as ie}from"./ServiceCodeErrorWindow-9a7fa518.js";import{b as ne}from"./service.version-5c9b6744.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=p("el-table-column"),u=p("el-table"),v=p("el-dialog");return a(),_(v,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=m=>s.visible=m),class:"vip-expired-window",width:"500px"},{default:f(()=>[c("div",re,[ae,oe,c("div",ce,[ue,h(u,{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=D(le,[["render",pe]]);const he={name:"ServiceInstaller",components:{VariableRemarkIcon:Q,VipExpiredWindow:de,FormItemTip:F,ServiceCodeErrorWindow:X,MergeWindow:x,ProjectSelect:R,DirectorySelect:B,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:{...O(["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]}},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()}},methods:{...L(["setInstallData"]),...N(["refreshBalance"]),...G(["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}M({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;if(l.inputType==="select"){let u=null,v=null;for(const m of s){const b=l.options.find(V=>V.value===m[l.name].value);if(b==null)return this.$tip.warning(`在「${n.label}」中,「${m.name}」字段缺少「${l.label}」`),!1;const w=b.settings;for(const V of w){if(!V.required)continue;const W=m[l.name].settings[V.name];S(W)&&(u=V,v=m)}}if(u!=null)return this.$tip.warning(`在「${n.label}」中,${v.name}」字段缺少「${u.label}」的设定`),!1}const r=s.find(u=>S(u[l.name]));if(r!=null)return this.$tip.warning(`在「${n.label}」中,「${r.name}」字段缺少「${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(S(n.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&&S(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&&l.value!=null&&(t=JSON.parse(JSON.stringify(l.value)))}}if(t==null){const s=this.projectConfig.service||this.projectConfig.main;if(s!=null){let l=null;for(const u in s){l=u;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 u of l)u[r.name]={value:u[r.name],settings:u[`${r.name}Settings`]},delete u[`${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=>(U("data-v-9aa53b58"),e=e(),z(),e),_e={class:"service-installer"},me={key:0,class:"nav"},ge={class:"title"},ye={key:0,class:"install"},ve=fe(()=>c("p",{class:"install-tip"},"安装提示: 填写以下信息并点击「立即安装」按钮即可安装代码到您项目目录中。",-1)),Ve={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"},Se={key:0},We={key:1,class:"parameters-holder"};function je(e,t,i,n,s,l){const r=p("el-option"),u=p("el-select"),v=p("el-button"),m=p("ProjectSelect"),b=p("FormItemTip"),w=p("el-form-item"),V=p("VariableRemarkIcon"),W=p("ArrowRight"),P=p("el-icon"),C=p("VariableInput"),q=p("el-form"),T=p("ServiceCodeErrorWindow"),E=p("VipExpiredWindow");return a(),d("div",_e,[i.withTitle?(a(),d("div",me,[c("div",ge,[c("h4",null,"@"+g(i.space)+"/"+g(i.service)+" · "+g(e.$t("service.install2"))+" · ",1),h(u,{size:"default",modelValue:s.selectedVersion,"onUpdate:modelValue":t[0]||(t[0]=o=>s.selectedVersion=o)},{default:f(()=>[(a(!0),d(k,null,j(i.versions,o=>(a(),_(r,{key:o,value:o},{default:f(()=>[I(g(o),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),i.withInstallButton?(a(),d("div",ye,[e.userInfo==null?(a(),_(v,{key:0,type:"important",onClick:t[1]||(t[1]=o=>e.$router.push({name:"SignIn"}))},{default:f(()=>[I("登录后可安装服务")]),_:1})):(a(),_(v,{key:1,type:"important",onClick:l.install,disabled:s.isWorking.install},{default:f(()=>[I(g(s.isWorking.install?e.$t("service.installing"):e.$t("service.install")),1)]),_:1},8,["onClick","disabled"]))])):y("",!0)])):y("",!0),c("div",{class:"content-wrap",style:J(l.contentWrapStyle)},[i.withProject||s.variables.length>0?(a(),d(k,{key:0},[ve,c("div",Ve,[h(q,null,{default:f(()=>[i.withProject?(a(),_(w,{key:0,label:"项目",required:"",class:"form-item-project"},{default:f(()=>[h(m,{"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(),_(b,{key:0,content:"服务安装后的代码将存放至指定的项目目录中,请先选择或创建一个项目!"})):(a(),_(b,{key:1,content:`服务安装后代码将写入<em>${e.currentProjectDetail.codespace}</em>目录。`},null,8,["content"]))]),_:1})):y("",!0),(a(!0),d(k,null,j(s.variables,o=>(a(),d(k,null,[o.hidden?y("",!0):(a(),_(w,{key:o.name,label:o.label,required:o.required},{label:f(()=>[c("div",be,[c("div",ke,[c("label",null,g(o.label),1),h(V,{variable:o},null,8,["variable"])]),o.type!=="variable"?(a(),d("div",we,[h(P,null,{default:f(()=>[h(W)]),_:1})])):y("",!0)])]),default:f(()=>[o.type==="variable"?(a(),_(C,{key:0,variable:o},null,8,["variable"])):o.type==="group"?(a(),d("ul",$e,[(a(!0),d(k,null,j(o.children,$=>(a(),d("li",{key:`${o.name}_${$.name}`},[c("label",Ie,[$.required?(a(),d("em",Se,"*")):y("",!0),I(g($.label),1)]),h(C,{variable:$},null,8,["variable"])]))),128))])):y("",!0),o.inputType==="datasource"&&e.getCurrentDatabaseDetail()!=null?(a(),_(b,{key:2,content:`路径:${e.getCurrentDatabaseDetail().host}:${e.getCurrentDatabaseDetail().port}/${e.getCurrentDatabaseDetail().schema}`},null,8,["content"])):y("",!0)]),_:2},1032,["label","required"]))],64))),256))]),_:1})])],64)):(a(),d("div",We,[c("p",null,g(e.$t("service.withoutParametersTip")),1)]))],4),h(T,{ref:"serviceCodeErrorWindow"},null,512),h(E,{ref:"vipExpiredWindow"},null,512)])}const Te=D(he,[["render",je],["__scopeId","data-v-9aa53b58"]]);export{Te as S};