2 lines
6.7 KiB
Java
2 lines
6.7 KiB
Java
var O=(n,o,a)=>new Promise((c,f)=>{var y=s=>{try{m(a.next(s))}catch(u){f(u)}},b=s=>{try{m(a.throw(s))}catch(u){f(u)}},m=s=>s.done?c(s.value):Promise.resolve(s.value).then(y,b);m((a=a.apply(n,o)).next())});import{cq as Z,bo as ee,d as te,bn as $,au as ne,bL as oe}from"./index-X7Y8jykP.js";import{B as le}from"./index-BDvqZ5j4.js";import{c as ae}from"./index-C69VKHba.js";/* empty css */import{f as x,e as ie,r as h,b as A,y as L,z,A as w,K as k,Q as T,T as V,H as re,E as W}from"./vue-vendor-DNhG1Cve.js";import{a as se}from"./useModal-DaJ3Bflg.js";import{O as ue}from"./index-CuWaQdlK.js";import{_ as de}from"./DirectoryTree-nk_YTTIy.js";var ce={icon:function(o,a){return{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z",fill:o}},{tag:"path",attrs:{d:"M512 140c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372zm32 588c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z",fill:a}},{tag:"path",attrs:{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z",fill:o}}]}},name:"info-circle",theme:"twotone"};function H(n){for(var o=1;o<arguments.length;o++){var a=arguments[o]!=null?Object(arguments[o]):{},c=Object.keys(a);typeof Object.getOwnPropertySymbols=="function"&&(c=c.concat(Object.getOwnPropertySymbols(a).filter(function(f){return Object.getOwnPropertyDescriptor(a,f).enumerable}))),c.forEach(function(f){fe(n,f,a[f])})}return n}function fe(n,o,a){return o in n?Object.defineProperty(n,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[o]=a,n}var E=function(o,a){var c=H({},o,a.attrs);return x(Z,H({},c,{icon:ce}),null)};E.displayName="InfoCircleTwoTone";E.inheritAttrs=!1;const pe=ie({name:"CodeFileViewModal",components:{BasicModal:le,InfoCircleTwoTone:E,JCodeEditor:ae},emits:["download","register","close"],setup(n,{emit:o}){const a=h([]),c=h(""),f=h([]),y=h(!1),b=window.innerHeight-142,m=h("java"),s=h("");let u=A({});const[B,{closeModal:F}]=se(t=>O(null,null,function*(){u=A({}),s.value="",a.value=t.codeList,c.value=t.pathKey,D(),Y(),y.value=!0})),{prefixCls:S}=ee("online-codeFileViewModal");function D(){let t=K(),i=t[0];R(i,t);let l=[];const e=function(p){if(p.children){let r=p.children;r.length==1?e(r[0]):r.length>1&&l.push(p)}};e(i),f.value=l,setTimeout(()=>{X(i)},300)}function X(t){return O(this,null,function*(){const i=function(e){if(e.isLeaf===!0)return e;if(e.children)return i(e.children[0])};let l=i(t);if(l&&l.isLeaf===!0){let e=l.path;u[e]||(yield I(e)),m.value=j(e),s.value=u[e]}})}function R(t,i){for(let l of i)t.key==l.pid&&(t.children||(t.children=[]),t.children.push(l),R(l,i))}function P(t,i){let l=0,e="";for(;l<=i;)e+=t[l],l++;return e}function K(){let t=[],i=[],l=a.value;for(let e of l){let p=e.replace(new RegExp("\\\\","g"),"/").replace("生成成功:","").trim();if(p){let r=p.split("/");for(let d=0;d<r.length;d++){let v=r[d],C=P(r,d);if(v){let g={title:v,key:C};if(v!=0){let _=P(r,d-1);_&&(g.pid=_)}d==r.length-1&&(g.isLeaf=!0,g.path=p),(i.indexOf(C)<0||d==r.length-1)&&(t.push(g),i.push(C))}}}}return t}function q(){F(),o("close")}function G(){o("download")}function j(t){return t.endsWith("xml")?"application/xml":t.endsWith("sql")?"text/x-sql":t.endsWith("vue")?"text/x-vue":t.endsWith("ts")?"text/typescript":"text/x-java"}function J(t,i){return O(this,null,function*(){let l=i.node.dataRef;if(l.isLeaf){let e=l.path;u[e]||(yield I(e)),m.value=j(e),s.value=u[e]}})}function I(t){return new Promise(i=>{let l={path:encodeURI(t),pathKey:c.value};te.get({url:"/online/cgform/api/codeView",params:l},{isTransformResponse:!1}).then(e=>{if(!e||e.size===0){$.warning("文件下载失败");return}else if(e.message){$.warning(e.message);return}let p=new Blob([e]),r=new FileReader;r.readAsText(p,"utf8"),r.onload=function(){let d=this.result;u[t]=d,i(1)}})})}const N=h(24),U=h(14),Q=h(30);function Y(){let t=document.getElementsByClassName("resize"),i=document.getElementsByClassName("code-gen"),l=document.getElementsByClassName("left");for(let e=0;e<t.length;e++)t[e].onmousedown=function(p){let r=i[e].offsetWidth,d=l[e].offsetWidth,v=p.clientX;return document.onmousemove=function(C){let g=C.clientX,_=Math.abs(g-v);if(g>v){let M=parseFloat(((d+_)/r*100).toFixed(4));parseFloat("100")-M>Q.value&&(N.value=M)}if(g<v){let M=parseFloat(((d-_)/r*100).toFixed(4));M>U.value&&(N.value=M)}},document.onmouseup=function(C){document.onmousemove=null,document.onmouseup=null,t[e].releaseCapture&&t[e].releaseCapture()},t[e].setCapture&&t[e].setCapture(),!1}}return{registerModal:B,codeList:a,onDownloadGenerateCode:G,handleClose:q,treeData:f,showCodeContent:J,activeCodeContent:s,expandStatus:y,height:b,language:m,prefixCls:S,modalHeight:1e3,defaultLeftWidthRate:N}}});function me(n,o,a,c,f,y){const b=k("info-circle-two-tone"),m=de,s=k("JCodeEditor"),u=oe,B=ue,F=k("a-button"),S=k("BasicModal");return z(),L(S,{height:n.modalHeight,onRegister:n.registerModal,okText:"",cancelText:"关闭",width:1200,defaultFullscreen:!0,canFullscreen:!1,onOk:n.onDownloadGenerateCode,wrapClassName:n.prefixCls},{title:w(()=>[x(b),o[1]||(o[1]=W(" 代码在线预览 ",-1))]),footer:w(()=>[x(F,{onClick:n.handleClose},{default:w(()=>[...o[3]||(o[3]=[W("关闭",-1)])]),_:1},8,["onClick"]),x(F,{type:"primary",onClick:n.onDownloadGenerateCode},{default:w(()=>[...o[4]||(o[4]=[W("下载到本地",-1)])]),_:1},8,["onClick"])]),default:w(()=>[T("div",null,[x(B,{class:"code-gen"},{default:w(()=>[T("div",{class:"left",style:V([{"border-right":"1px solid #eee"},{width:`calc(${n.defaultLeftWidthRate}% - 2px)`}])},[T("div",{style:V({height:n.height+"px",overflowY:"auto"})},[n.treeData.length?(z(),L(m,{key:0,defaultExpandAll:!0,"tree-data":n.treeData,onSelect:n.showCodeContent},null,8,["tree-data","onSelect"])):re("",!0)],4)],4),o[2]||(o[2]=T("div",{class:"resize"},null,-1)),T("div",{class:"right",style:V({width:`calc(100% - ${n.defaultLeftWidthRate}% - 2px)`})},[n.activeCodeContent?(z(),L(s,{key:0,value:n.activeCodeContent,"onUpdate:value":o[0]||(o[0]=D=>n.activeCodeContent=D),theme:"idea",language:n.language,fullScreen:!1,lineNumbers:!0,height:n.height+"px",disabled:!0,"language-change":!0},null,8,["value","language","height"])):(z(),L(u,{key:1,style:{"margin-top":"50px"},description:"请选择左侧文件,显示详细代码"}))],4)]),_:1})])]),_:1},8,["height","onRegister","onOk","wrapClassName"])}const he=ne(pe,[["render",me]]),Fe=Object.freeze(Object.defineProperty({__proto__:null,default:he},Symbol.toStringTag,{value:"Module"}));export{he as C,E as I,Fe as a};
|