All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.app.63d2a490.js Maven / Gradle / Ivy

The newest version!
(function(){"use strict";var e={7137:function(e,t,r){var o=r(8935),a=r(4549),l=r.n(a),i=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{attrs:{id:"app"}},[r("CodeGenerator")],1)},s=[],n=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("el-container",[o("el-header",[o("div",{staticStyle:{float:"left"}},[o("img",{attrs:{src:r(9574),alt:"logo"}}),o("span",{staticStyle:{"margin-left":"20px",color:"#fff"}},[e._v("代码生成器")])])]),o("el-main",[o("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"120px"}},[o("el-row",{attrs:{gutter:20}},[o("el-col",{attrs:{span:6}},[o("el-form-item",{attrs:{label:"数据库",prop:"dbName"}},[o("el-select",{staticStyle:{float:"left",width:"100%"},attrs:{placeholder:"请选择数据库",filterable:"",clearable:!0},on:{change:e.selDatabase},model:{value:e.form.dbName,callback:function(t){e.$set(e.form,"dbName",t)},expression:"form.dbName"}},e._l(e.databases,(function(e,t){return o("el-option",{key:t,attrs:{label:e,value:e}})})),1)],1)],1),o("el-col",{attrs:{span:18}},[o("el-form-item",{attrs:{label:"数据表",prop:"includeTableNames"}},[o("el-select",{staticStyle:{float:"left",width:"100%"},attrs:{placeholder:"请选择数据表(为空则全选)",multiple:"",filterable:""},model:{value:e.form.includeTableNames,callback:function(t){e.$set(e.form,"includeTableNames",t)},expression:"form.includeTableNames"}},e._l(e.tableNames,(function(t,r){return o("el-option",{key:r,attrs:{value:t.name}},[e._v(" "+e._s(t.name)+e._s(t.comment)+" ")])})),1)],1)],1)],1),o("el-row",{attrs:{gutter:20}},[o("el-col",{attrs:{span:8}},[o("el-form-item",{attrs:{label:"服务名",prop:"serverName"}},[o("el-tooltip",{attrs:{content:"默认为数据库名,如果自定义则只需填写关键单词即可,系统会默认添加前缀cunw和后缀server"}},[o("el-input",{attrs:{placeholder:"请输入服务名"},model:{value:e.form.serverName,callback:function(t){e.$set(e.form,"serverName",t)},expression:"form.serverName"}})],1)],1)],1),o("el-col",{attrs:{span:8}},[o("el-form-item",{attrs:{label:"模块名",prop:"moduleName"}},[o("el-tooltip",{attrs:{content:"默认实现为正则表达式去取表名第一个符合的单词,如遇到Java关键字则按下划线拆解符合的下个单词;如修改为固定单词则去修改的为模块名"}},[o("el-input",{attrs:{placeholder:"请输入模块名"},model:{value:e.form.moduleName,callback:function(t){e.$set(e.form,"moduleName",t)},expression:"form.moduleName"}})],1)],1)],1),o("el-col",{attrs:{span:8}},[o("el-form-item",{attrs:{label:"表名规则",prop:"tableNameRuleRegex"}},[o("el-tooltip",{attrs:{content:"通过正则表达式获取表名的规则,为空则表示直接使用表名"}},[o("el-input",{model:{value:e.form.tableNameRuleRegex,callback:function(t){e.$set(e.form,"tableNameRuleRegex",t)},expression:"form.tableNameRuleRegex"}})],1)],1)],1)],1),o("el-form-item",{attrs:{label:"基础包名",prop:"basePackageName"}},[o("el-input",{attrs:{placeholder:"请输入基础包名"},model:{value:e.form.basePackageName,callback:function(t){e.$set(e.form,"basePackageName",t)},expression:"form.basePackageName"}})],1),o("el-row",{attrs:{gutter:20}},[o("el-col",{attrs:{span:6}},[o("el-form-item",{attrs:{label:"生成分类",prop:"includeGroup"}},[o("el-radio-group",{on:{change:e.handGroupChange},model:{value:e.form.includeGroup,callback:function(t){e.$set(e.form,"includeGroup",t)},expression:"form.includeGroup"}},e._l(e.exportFileGroups,(function(t,r){return o("el-radio-button",{key:r,attrs:{label:t.val}},[e._v(e._s(t.title))])})),1)],1)],1)],1),e.fileCustomSelected?o("el-row",{attrs:{gutter:20}},[o("el-col",{attrs:{span:24}},[o("el-form-item",{attrs:{label:"生成文件",prop:"includeFileTypes"}},[o("el-select",{staticStyle:{float:"left",width:"100%"},attrs:{placeholder:"请选择生成文件类型(为空则全选)",multiple:"",filterable:""},model:{value:e.form.includeFileTypes,callback:function(t){e.$set(e.form,"includeFileTypes",t)},expression:"form.includeFileTypes"}},e._l(e.exportFileTypes,(function(e,t){return o("el-option",{key:t,attrs:{value:e,label:e}})})),1)],1)],1)],1):e._e(),o("el-row",{attrs:{gutter:20}},[o("el-col",{attrs:{span:3}},[o("el-form-item",{attrs:{label:"是否服务化",prop:"hasProvideService"}},[o("el-switch",{model:{value:e.form.hasProvideService,callback:function(t){e.$set(e.form,"hasProvideService",t)},expression:"form.hasProvideService"}})],1)],1),o("el-col",{attrs:{span:3}},[o("el-form-item",{attrs:{label:"是否BaseApi",prop:"hasBaseApi"}},[o("el-switch",{model:{value:e.form.hasBaseApi,callback:function(t){e.$set(e.form,"hasBaseApi",t)},expression:"form.hasBaseApi"}})],1)],1),o("el-col",{attrs:{span:3}},[o("el-form-item",{attrs:{label:"是否ORM",prop:"hasOrm"}},[o("el-switch",{model:{value:e.form.hasOrm,callback:function(t){e.$set(e.form,"hasOrm",t)},expression:"form.hasOrm"}})],1)],1),o("el-col",{attrs:{span:3}},[o("el-form-item",{attrs:{label:"是否微服务",prop:"hasMicro"}},[o("el-switch",{model:{value:e.form.hasMicro,callback:function(t){e.$set(e.form,"hasMicro",t)},expression:"form.hasMicro"}})],1)],1)],1),o("el-form-item",[o("el-button",{attrs:{type:"success"},on:{click:e.codePreview}},[e._v("代码预览")]),e.alone?e._e():o("el-button",{attrs:{type:"info"},on:{click:e.codeLocal}},[e._v("本地生成")]),o("el-button",{attrs:{type:"primary"},on:{click:e.codeDownload}},[e._v("立即下载")]),o("el-button",{attrs:{type:"danger"},on:{click:e.resetForm}},[e._v("重置")])],1)],1),e.previewVisible?o("el-dialog",{attrs:{title:"代码预览",width:"80%",visible:e.previewVisible,"destroy-on-close":!0,"append-to-body":""},on:{"update:visible":function(t){e.previewVisible=t}}},[o("CodePreview",{attrs:{form:e.form}}),o("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[o("el-button",{on:{click:function(t){e.previewVisible=!1}}},[e._v("取消")]),e.alone?e._e():o("el-button",{attrs:{type:"info"},on:{click:e.codeLocal}},[e._v("本地生成")]),o("el-button",{attrs:{type:"primary"},on:{click:e.codeDownload}},[e._v("立即下载")])],1)],1):e._e()],1)],1)},c=[],u=r(6166),m=r.n(u);m().defaults.headers["Content-Type"]="application/json;charset=utf-8";const d=m().create({baseURL:"/codegen",timeout:1e4});d.interceptors.request.use((e=>e)),d.interceptors.response.use((e=>{if("blob"===e.request.responseType||"arraybuffer"===e.request.responseType)return e.data;const t=e.data["code"]||0,r=e.data["error"]||e.data["message"]||"";return 0!==t?(a.Notification.error(r),Promise.reject(r)):e.data["data"]}));var f=d,p=r(3706);function h(){return f({url:"/get-alone",method:"get"})}function b(){return f({url:"/get-file-types",method:"get"})}function v(){return f({url:"/get-databases",method:"get"})}function g(e){return f({url:`/${e}/tables`,method:"get"})}function y(e){const t=e||"正在加载数据,请求稍后。。。";return a.Loading.service({text:t,spinner:"el-icon-loading",background:"rgba(0,0,0,0.7)"})}function N(e){e&&(e.close(),e=null)}function w(e){let t=y("正在预览代码,请稍候...");return f({url:"/preview",method:"post",data:e}).then((e=>(N(t),new Promise((t=>t(e)))))).catch((()=>{N(t)}))}function k(e,t){let r=y("正在下载文件,请稍候...");return f({url:"/download",method:"post",data:e,responseType:"blob"}).then((async e=>{const o=new Blob([e]);if(navigator.msSaveBlob)navigator.msSaveBlob(o,t);else{const e=window.URL.createObjectURL(o);(0,p.saveAs)(e,t)}N(r)})).catch((e=>{N(r),console.error(e),a.Message.error("下载文件出现错误,请联系管理员!")}))}function _(e){let t=y("正在生成本地文件,请稍候...");return f({url:"/local",method:"post",data:e}).then((e=>(N(t),new Promise((t=>t(e)))))).catch((()=>{N(t)}))}var T=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("el-container",[r("el-aside",[r("el-tree",{attrs:{data:e.fileTree,props:e.fileTreeProps},on:{"node-click":e.handleFileTreeNode}})],1),r("el-main",[r("p",[e._v(e._s(e.codeFileName))]),r("pre",[e._v("      "),r("code",{staticClass:"hljs",domProps:{innerHTML:e._s(e.codeContent)}}),e._v("\n    ")])])],1)},x=[],P=(r(6699),r(7323));r(1278);P.Z.registerLanguage("java",r(8951)),P.Z.registerLanguage("html",r(7525)),P.Z.registerLanguage("xml",r(7525)),P.Z.registerLanguage("sh",r(1704)),P.Z.registerLanguage("vue",r(7525)),P.Z.registerLanguage("javascript",r(4390)),P.Z.registerLanguage("sql",r(9984)),P.Z.registerLanguage("gitignore",r(1704)),P.Z.registerLanguage("properties",r(1704));var F={name:"CodePreview",props:{form:{type:Object,required:!0}},data(){return{codeFileName:"",codeContent:"",codeFiles:[],fileTree:[],fileTreeProps:{label:"label",children:"children"}}},created(){w(this.form).then((e=>{this.codeFiles=e||[],this.fileTree=[],this.buildFileTree()}))},methods:{buildFileTree(){const e={};if(this.codeFiles.forEach((t=>{const r=t["dir"]||"",o=t["name"],a=t["content"];if(r&&o&&a){const t="\\",l="/";let i=[];if(r.includes(t))i=r.split(t);else if(r.includes(l)){let e=r.replace("src/main/java","src-main-java").replace("src/main/resources","src-main-resources");i=e.split(l)}else i=[r];const s=i.length;for(let r=0;r{const o=e[r];!o||""!==o.pid&&e[o.pid]||(o["children"]=[],this.buildTreeChild(o,e),t.push(o))})),this.fileTree=t||[]}},buildTreeChild(e,t){e&&t&&Object.keys(t).map((r=>{const o=t[r];o&&o.pid&&o.pid===e.id&&(o["children"]=[],this.buildTreeChild(o,t),e.children.push(o))}))},buildPathKey(e,t){if(e&&t>=0){const r="_",o=e.length;if(o>t){const o=[];for(let r=0;r<=t;r++){let t=e[r];t&&o.push(t)}return`k${r}${(o.join(r)||"").trim()}`}}return""},handleFileTreeNode(e){let t;(t=e["content"])&&(this.codeFileName=e["label"],this.codeContent=this.highlightedCode(this.codeFileName,t))},highlightedCode(e,t){if(e&&t){const r=e.lastIndexOf("."),o=r>0?e.substring(r+1):"sh",a=P.Z.highlight(o,t);return a.value||t}return t}}},$=F,C=r(1001),O=(0,C.Z)($,T,x,!1,null,"0e1c169e",null),S=O.exports,j={name:"CodeGenerator",components:{CodePreview:S},data(){return{alone:!1,previewVisible:!1,databases:[],tableNames:[],exportFileTypes:[],exportFileGroups:[{val:"Api,Common,Service",title:"模块"},{val:"",title:"项目"},{val:"A1",title:"自定义"}],fileCustomSelected:!1,form:{serverName:"",moduleName:"^([a-z]+)",basePackageName:"",dbName:"",tableNameRuleRegex:"([a-z]+)$",includeTableNames:[],includeGroup:"Api,Common,Service",includeFileTypes:[],hasProvideService:!0,hasBaseApi:!0,hasOrm:!0,hasMicro:!0},rules:{serverName:[{required:!0,message:"请输入服务名",trigger:"blur"}],moduleName:[{required:!0,message:"请输入模块名",trigger:"blur"}],dbName:[{required:!0,message:"请输入数据库名",trigger:"blur"}],basePackageName:[{required:!0,message:"请输入基础包名",trigger:"blur"}]}}},created(){h().then((e=>{this.alone=e||!1})),b().then((e=>{this.exportFileTypes=e||[]})),v().then((e=>{this.databases=e||[]}))},methods:{selDatabase(e){this.tableNames=[],""!==e&&(""===this.form.serverName&&(this.form.serverName=e),""===this.form.moduleName&&(this.form.moduleName=e),""===this.form.basePackageName&&(this.form.basePackageName=`top.zenyoung.cloud.${e}`),g(e).then((e=>{this.tableNames=e||[]})))},handGroupChange(e){""===e||/^[A-Z|a-z|,]+$/.test(e)?(this.fileCustomSelected=!1,this.form.includeFileTypes=[]):this.fileCustomSelected=!0},codePreview(){this.submitForm((()=>{this.previewVisible=!0}))},codeLocal(){this.submitForm((()=>{_(this.form)}))},codeDownload(){this.submitForm((()=>{k(this.form,`zy-${this.form.serverName}.zip`)}))},submitForm(e){this.$refs.form.validate((t=>{if(!t)return console.log("error submit!"),!1;e()}))},resetForm(){this.$refs.form.resetFields()}}},L=j,R=(0,C.Z)(L,n,c,!1,null,"07f37194",null),Z=R.exports,A={name:"App",components:{CodeGenerator:Z}},G=A,M=(0,C.Z)(G,i,s,!1,null,null,null),q=M.exports;o["default"].config.productionTip=!1,o["default"].use(l()),new o["default"]({render:e=>e(q)}).$mount("#app")},9574:function(e,t,r){e.exports=r.p+"img/logo.4ce1668d.svg"}},t={};function r(o){var a=t[o];if(void 0!==a)return a.exports;var l=t[o]={exports:{}};return e[o].call(l.exports,l,l.exports,r),l.exports}r.m=e,function(){var e=[];r.O=function(t,o,a,l){if(!o){var i=1/0;for(u=0;u=l)&&Object.keys(r.O).every((function(e){return r.O[e](o[n])}))?o.splice(n--,1):(s=!1,l0&&e[u-1][2]>l;u--)e[u]=e[u-1];e[u]=[o,a,l]}}(),function(){r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,{a:t}),t}}(),function(){r.d=function(e,t){for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}}(),function(){r.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){r.p="/"}(),function(){var e={143:0};r.O.j=function(t){return 0===e[t]};var t=function(t,o){var a,l,i=o[0],s=o[1],n=o[2],c=0;if(i.some((function(t){return 0!==e[t]}))){for(a in s)r.o(s,a)&&(r.m[a]=s[a]);if(n)var u=n(r)}for(t&&t(o);c




© 2015 - 2024 Weber Informatics LLC | Privacy Policy