META-INF.resources.js.app-legacy.73ebd3de.js Maven / Gradle / Ivy
The newest version!
(function(){"use strict";var e={17137:function(e,t,r){r(66992),r(88674),r(19601),r(17727);var a=r(28935),o=r(74549),n=r.n(o),l=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{attrs:{id:"app"}},[r("CodeGenerator")],1)},i=[],s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("el-container",[a("el-header",[a("div",{staticStyle:{float:"left"}},[a("img",{attrs:{src:r(69574),alt:"logo"}}),a("span",{staticStyle:{"margin-left":"20px",color:"#fff"}},[e._v("代码生成器")])])]),a("el-main",[a("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"120px"}},[a("el-row",{attrs:{gutter:20}},[a("el-col",{attrs:{span:6}},[a("el-form-item",{attrs:{label:"数据库",prop:"dbName"}},[a("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 a("el-option",{key:t,attrs:{label:e,value:e}})})),1)],1)],1),a("el-col",{attrs:{span:18}},[a("el-form-item",{attrs:{label:"数据表",prop:"includeTableNames"}},[a("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 a("el-option",{key:r,attrs:{value:t.name}},[e._v(" "+e._s(t.name)+e._s(t.comment)+" ")])})),1)],1)],1)],1),a("el-row",{attrs:{gutter:20}},[a("el-col",{attrs:{span:8}},[a("el-form-item",{attrs:{label:"服务名",prop:"serverName"}},[a("el-tooltip",{attrs:{content:"默认为数据库名,如果自定义则只需填写关键单词即可,系统会默认添加前缀cunw和后缀server"}},[a("el-input",{attrs:{placeholder:"请输入服务名"},model:{value:e.form.serverName,callback:function(t){e.$set(e.form,"serverName",t)},expression:"form.serverName"}})],1)],1)],1),a("el-col",{attrs:{span:8}},[a("el-form-item",{attrs:{label:"模块名",prop:"moduleName"}},[a("el-tooltip",{attrs:{content:"默认实现为正则表达式去取表名第一个符合的单词,如遇到Java关键字则按下划线拆解符合的下个单词;如修改为固定单词则去修改的为模块名"}},[a("el-input",{attrs:{placeholder:"请输入模块名"},model:{value:e.form.moduleName,callback:function(t){e.$set(e.form,"moduleName",t)},expression:"form.moduleName"}})],1)],1)],1),a("el-col",{attrs:{span:8}},[a("el-form-item",{attrs:{label:"表名规则",prop:"tableNameRuleRegex"}},[a("el-tooltip",{attrs:{content:"通过正则表达式获取表名的规则,为空则表示直接使用表名"}},[a("el-input",{model:{value:e.form.tableNameRuleRegex,callback:function(t){e.$set(e.form,"tableNameRuleRegex",t)},expression:"form.tableNameRuleRegex"}})],1)],1)],1)],1),a("el-form-item",{attrs:{label:"基础包名",prop:"basePackageName"}},[a("el-input",{attrs:{placeholder:"请输入基础包名"},model:{value:e.form.basePackageName,callback:function(t){e.$set(e.form,"basePackageName",t)},expression:"form.basePackageName"}})],1),a("el-row",{attrs:{gutter:20}},[a("el-col",{attrs:{span:6}},[a("el-form-item",{attrs:{label:"生成分类",prop:"includeGroup"}},[a("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 a("el-radio-button",{key:r,attrs:{label:t.val}},[e._v(e._s(t.title))])})),1)],1)],1)],1),e.fileCustomSelected?a("el-row",{attrs:{gutter:20}},[a("el-col",{attrs:{span:24}},[a("el-form-item",{attrs:{label:"生成文件",prop:"includeFileTypes"}},[a("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 a("el-option",{key:t,attrs:{value:e,label:e}})})),1)],1)],1)],1):e._e(),a("el-row",{attrs:{gutter:20}},[a("el-col",{attrs:{span:3}},[a("el-form-item",{attrs:{label:"是否服务化",prop:"hasProvideService"}},[a("el-switch",{model:{value:e.form.hasProvideService,callback:function(t){e.$set(e.form,"hasProvideService",t)},expression:"form.hasProvideService"}})],1)],1),a("el-col",{attrs:{span:3}},[a("el-form-item",{attrs:{label:"是否BaseApi",prop:"hasBaseApi"}},[a("el-switch",{model:{value:e.form.hasBaseApi,callback:function(t){e.$set(e.form,"hasBaseApi",t)},expression:"form.hasBaseApi"}})],1)],1),a("el-col",{attrs:{span:3}},[a("el-form-item",{attrs:{label:"是否ORM",prop:"hasOrm"}},[a("el-switch",{model:{value:e.form.hasOrm,callback:function(t){e.$set(e.form,"hasOrm",t)},expression:"form.hasOrm"}})],1)],1),a("el-col",{attrs:{span:3}},[a("el-form-item",{attrs:{label:"是否微服务",prop:"hasMicro"}},[a("el-switch",{model:{value:e.form.hasMicro,callback:function(t){e.$set(e.form,"hasMicro",t)},expression:"form.hasMicro"}})],1)],1)],1),a("el-form-item",[a("el-button",{attrs:{type:"success"},on:{click:e.codePreview}},[e._v("代码预览")]),e.alone?e._e():a("el-button",{attrs:{type:"info"},on:{click:e.codeLocal}},[e._v("本地生成")]),a("el-button",{attrs:{type:"primary"},on:{click:e.codeDownload}},[e._v("立即下载")]),a("el-button",{attrs:{type:"danger"},on:{click:e.resetForm}},[e._v("重置")])],1)],1),e.previewVisible?a("el-dialog",{attrs:{title:"代码预览",width:"80%",visible:e.previewVisible,"destroy-on-close":!0,"append-to-body":""},on:{"update:visible":function(t){e.previewVisible=t}}},[a("CodePreview",{attrs:{form:e.form}}),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.previewVisible=!1}}},[e._v("取消")]),e.alone?e._e():a("el-button",{attrs:{type:"info"},on:{click:e.codeLocal}},[e._v("本地生成")]),a("el-button",{attrs:{type:"primary"},on:{click:e.codeDownload}},[e._v("立即下载")])],1)],1):e._e()],1)],1)},c=[],u=(r(74916),r(77601),r(67906)),f=r(16198),m=(r(41539),r(78783),r(33948),r(60285),r(41637),r(26166)),d=r.n(m);d().defaults.headers["Content-Type"]="application/json;charset=utf-8";var p=d().create({baseURL:"/codegen",timeout:1e4});p.interceptors.request.use((function(e){return e})),p.interceptors.response.use((function(e){if("blob"===e.request.responseType||"arraybuffer"===e.request.responseType)return e.data;var t=e.data["code"]||0,r=e.data["error"]||e.data["message"]||"";return 0!==t?(o.Notification.error(r),Promise.reject(r)):e.data["data"]}));var v=p,h=r(53706);function b(){return v({url:"/get-alone",method:"get"})}function g(){return v({url:"/get-file-types",method:"get"})}function y(){return v({url:"/get-databases",method:"get"})}function N(e){return v({url:"/".concat(e,"/tables"),method:"get"})}function w(e){var t=e||"正在加载数据,请求稍后。。。";return o.Loading.service({text:t,spinner:"el-icon-loading",background:"rgba(0,0,0,0.7)"})}function k(e){e&&(e.close(),e=null)}function _(e){var t=w("正在预览代码,请稍候...");return v({url:"/preview",method:"post",data:e}).then((function(e){return k(t),new Promise((function(t){return t(e)}))})).catch((function(){k(t)}))}function x(e,t){var r=w("正在下载文件,请稍候...");return v({url:"/download",method:"post",data:e,responseType:"blob"}).then(function(){var e=(0,f.Z)((0,u.Z)().mark((function e(a){var o,n;return(0,u.Z)().wrap((function(e){while(1)switch(e.prev=e.next){case 0:o=new Blob([a]),navigator.msSaveBlob?navigator.msSaveBlob(o,t):(n=window.URL.createObjectURL(o),(0,h.saveAs)(n,t)),k(r);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){k(r),console.error(e),o.Message.error("下载文件出现错误,请联系管理员!")}))}function T(e){var t=w("正在生成本地文件,请稍候...");return v({url:"/local",method:"post",data:e}).then((function(e){return k(t),new Promise((function(t){return t(e)}))})).catch((function(){k(t)}))}var P=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)},F=[],C=(r(54747),r(68309),r(26699),r(32023),r(23123),r(15306),r(92222),r(21249),r(47941),r(73210),r(69600),r(17323));r(21278);C.Z.registerLanguage("java",r(78951)),C.Z.registerLanguage("html",r(17525)),C.Z.registerLanguage("xml",r(17525)),C.Z.registerLanguage("sh",r(81704)),C.Z.registerLanguage("vue",r(17525)),C.Z.registerLanguage("javascript",r(64390)),C.Z.registerLanguage("sql",r(59984)),C.Z.registerLanguage("gitignore",r(81704)),C.Z.registerLanguage("properties",r(81704));var O={name:"CodePreview",props:{form:{type:Object,required:!0}},data:function(){return{codeFileName:"",codeContent:"",codeFiles:[],fileTree:[],fileTreeProps:{label:"label",children:"children"}}},created:function(){var e=this;_(this.form).then((function(t){e.codeFiles=t||[],e.fileTree=[],e.buildFileTree()}))},methods:{buildFileTree:function(){var e=this,t={};if(this.codeFiles.forEach((function(r){var a=r["dir"]||"",o=r["name"],n=r["content"];if(a&&o&&n){var l="\\",i="/",s=[];if(a.includes(l))s=a.split(l);else if(a.includes(i)){var c=a.replace("src/main/java","src-main-java").replace("src/main/resources","src-main-resources");s=c.split(i)}else s=[a];for(var u=s.length,f=0;f=0){var r="_",a=e.length;if(a>t){for(var o=[],n=0;n<=t;n++){var l=e[n];l&&o.push(l)}return"k".concat(r).concat((o.join(r)||"").trim())}}return""},handleFileTreeNode:function(e){var t;(t=e["content"])&&(this.codeFileName=e["label"],this.codeContent=this.highlightedCode(this.codeFileName,t))},highlightedCode:function(e,t){if(e&&t){var r=e.lastIndexOf("."),a=r>0?e.substring(r+1):"sh",o=C.Z.highlight(a,t);return o.value||t}return t}}},S=O,j=r(1001),$=(0,j.Z)(S,P,F,!1,null,"0e1c169e",null),L=$.exports,Z={name:"CodeGenerator",components:{CodePreview:L},data:function(){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:function(){var e=this;b().then((function(t){e.alone=t||!1})),g().then((function(t){e.exportFileTypes=t||[]})),y().then((function(t){e.databases=t||[]}))},methods:{selDatabase:function(e){var t=this;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.".concat(e)),N(e).then((function(e){t.tableNames=e||[]})))},handGroupChange:function(e){""===e||/^[A-Z|a-z|,]+$/.test(e)?(this.fileCustomSelected=!1,this.form.includeFileTypes=[]):this.fileCustomSelected=!0},codePreview:function(){var e=this;this.submitForm((function(){e.previewVisible=!0}))},codeLocal:function(){var e=this;this.submitForm((function(){T(e.form)}))},codeDownload:function(){var e=this;this.submitForm((function(){x(e.form,"zy-".concat(e.form.serverName,".zip"))}))},submitForm:function(e){this.$refs.form.validate((function(t){if(!t)return console.log("error submit!"),!1;e()}))},resetForm:function(){this.$refs.form.resetFields()}}},R=Z,A=(0,j.Z)(R,s,c,!1,null,"07f37194",null),G=A.exports,M={name:"App",components:{CodeGenerator:G}},q=M,B=(0,j.Z)(q,l,i,!1,null,null,null),z=B.exports;a["default"].config.productionTip=!1,a["default"].use(n()),new a["default"]({render:function(e){return e(z)}}).$mount("#app")},69574:function(e,t,r){e.exports=r.p+"img/logo.4ce1668d.svg"}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,r),n.exports}r.m=e,function(){var e=[];r.O=function(t,a,o,n){if(!a){var l=1/0;for(u=0;u=n)&&Object.keys(r.O).every((function(e){return r.O[e](a[s])}))?a.splice(s--,1):(i=!1,n0&&e[u-1][2]>n;u--)e[u]=e[u-1];e[u]=[a,o,n]}}(),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 a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}}(),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,a){var o,n,l=a[0],i=a[1],s=a[2],c=0;if(l.some((function(t){return 0!==e[t]}))){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(s)var u=s(r)}for(t&&t(a);c