2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{d as H,r as g,al as Z,bF as ie,dl as re,o as r,b as T,e as _,aM as ne,Z as ce,a0 as ue,bs as de,q as _e,bT as me,c as d,w as s,f as t,g as w,h,au as A,t as W,cs as G,B as ee,X as O,x as pe,bE as U,ai as z,F as he,ap as fe,aj as ve,a8 as ge,_ as be,de as ye,df as ke,cP as xe,cQ as we,a3 as te,l as Se}from"./index-BxI_8ir5.js";import{a as $e,_ as Ie}from"./CollapseItem-CUobLCgj.js";const ze={scrollbarProps:Object,items:{type:Array,default:()=>[]},itemSize:{type:Number,required:!0},itemResizable:Boolean,itemsStyle:[String,Object],visibleItemsTag:{type:[String,Object],default:"div"},visibleItemsProps:Object,ignoreItemResize:Boolean,onScroll:Function,onWheel:Function,onResize:Function,defaultScrollKey:[Number,String],defaultScrollIndex:Number,keyField:{type:String,default:"key"},paddingTop:{type:[Number,String],default:0},paddingBottom:{type:[Number,String],default:0}},Te=H({name:"VirtualList",props:ze,setup(u){const l=g(null),f=g(null);function m(){const{value:i}=l;i&&i.sync()}function S(i){var a;m(),(a=u.onScroll)===null||a===void 0||a.call(u,i)}function C(i){var a;m(),(a=u.onResize)===null||a===void 0||a.call(u,i)}function N(i){var a;(a=u.onWheel)===null||a===void 0||a.call(u,i)}function b(i,a){var k,x;typeof i=="number"?(k=f.value)===null||k===void 0||k.scrollTo(i,a??0):(x=f.value)===null||x===void 0||x.scrollTo(i)}function p(){var i;return(i=f.value)===null||i===void 0?void 0:i.listElRef}function $(){var i;return(i=f.value)===null||i===void 0?void 0:i.itemsElRef}return{scrollTo:b,scrollbarInstRef:l,virtualListInstRef:f,getScrollContainer:p,getScrollContent:$,handleScroll:S,handleResize:C,handleWheel:N}},render(){return Z(re,Object.assign({},this.scrollbarProps,{ref:"scrollbarInstRef",container:this.getScrollContainer,content:this.getScrollContent}),{default:()=>Z(ie,{ref:"virtualListInstRef",showScrollbar:!1,items:this.items,itemSize:this.itemSize,itemResizable:this.itemResizable,itemsStyle:this.itemsStyle,visibleItemsTag:this.visibleItemsTag,visibleItemsProps:this.visibleItemsProps,ignoreItemResize:this.ignoreItemResize,keyField:this.keyField,defaultScrollKey:this.defaultScrollKey,defaultScrollIndex:this.defaultScrollIndex,paddingTop:this.paddingTop,paddingBottom:this.paddingBottom,onScroll:this.handleScroll,onResize:this.handleResize,onWheel:this.handleWheel},{default:({item:u,index:l})=>{var f,m;return(m=(f=this.$slots).default)===null||m===void 0?void 0:m.call(f,{item:u,index:l})}})})}}),Ce={class:"inline-block",viewBox:"0 0 14 14",width:"1em",height:"1em"},je=_("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[_("path",{d:"M10.13 3.48L7.26.61a.36.36 0 0 0-.52 0L3.87 3.48m6.26 7.04l-2.87 2.87a.36.36 0 0 1-.52 0l-2.87-2.87"}),_("circle",{cx:"7",cy:"7",r:"1.25"})],-1),Be=[je];function De(u,l){return r(),T("svg",Ce,[...Be])}const Ne={name:"streamline-interface-arrows-vertical-scroll-point-move-scroll-vertical",render:De},Me={class:"inline-block",viewBox:"0 0 14 14",width:"1em",height:"1em"},Le=_("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[_("path",{d:"m5 11l.5 2l-2 .5"}),_("path",{d:"M5.5 13A6.76 6.76 0 0 1 1 7a6 6 0 0 1 .66-2.736M4.95 1.36a6 6 0 0 0-2.19 1.394M9 3l-.5-2l2-.5"}),_("path",{d:"M8.5 1c2.3.84 4.5 3.42 4.5 6a6 6 0 0 1-1.731 4.2M9 12.64c.22-.078.434-.168.642-.27M.5.5l13 13"})],-1),Re=[Le];function Fe(u,l){return r(),T("svg",Me,[...Re])}const Ve={name:"streamline-synchronize-disable",render:Fe},qe={class:"inline-block",viewBox:"0 0 24 24",width:"1em",height:"1em"},Ee=_("path",{fill:"currentColor","fill-rule":"evenodd",d:"M2.93 11.2c.072-4.96 4.146-8.95 9.149-8.95a9.158 9.158 0 0 1 7.814 4.357a.75.75 0 0 1-1.277.786a7.658 7.658 0 0 0-6.537-3.643c-4.185 0-7.575 3.328-7.648 7.448l.4-.397a.75.75 0 0 1 1.057 1.065l-1.68 1.666a.75.75 0 0 1-1.056 0l-1.68-1.666A.75.75 0 1 1 2.528 10.8zm16.856-.733a.75.75 0 0 1 1.055 0l1.686 1.666a.75.75 0 1 1-1.054 1.067l-.41-.405c-.07 4.965-4.161 8.955-9.18 8.955a9.197 9.197 0 0 1-7.842-4.356a.75.75 0 1 1 1.277-.788a7.697 7.697 0 0 0 6.565 3.644c4.206 0 7.61-3.333 7.68-7.453l-.408.403a.75.75 0 1 1-1.055-1.067z","clip-rule":"evenodd"},null,-1),Ae=[Ee];function Oe(u,l){return r(),T("svg",qe,[...Ae])}const Pe={name:"solar-refresh-outline",render:Oe},We={class:"inline-block",viewBox:"0 0 16 16",width:"1em",height:"1em"},Ue=_("path",{fill:"currentColor","fill-rule":"evenodd",d:"M7.706.29c-.222.072-.35.2-.412.409c-.035.117-.041.389-.041 1.809c0 1.881-.002 1.857.19 2.049c.257.256.857.256 1.114 0c.192-.192.19-.168.19-2.049c0-1.82-.003-1.852-.151-2.028C8.472.333 8.339.284 8.04.276a1.705 1.705 0 0 0-.334.014M2.753 2.266c-.158.072-.391.3-.472.462a.605.605 0 0 0-.012.525c.074.165 2.398 2.497 2.581 2.59c.259.133.525.068.793-.194c.264-.258.334-.538.2-.799c-.093-.183-2.425-2.507-2.59-2.581a.638.638 0 0 0-.5-.003m10.1.016c-.123.057-.333.254-1.335 1.259c-.921.923-1.202 1.221-1.247 1.319a.617.617 0 0 0 .001.518c.07.15.3.386.455.467c.157.082.39.081.553-.002c.167-.086 2.477-2.396 2.563-2.563a.648.648 0 0 0 .003-.551a1.26 1.26 0 0 0-.454-.446a.569.569 0 0 0-.539-.001M.699 7.292c-.295.093-.441.328-.441.707c.001.387.145.619.44.707c.118.035.381.041 1.81.041c1.489 0 1.688-.005 1.81-.045a.602.602 0 0 0 .384-.384c.086-.265.043-.641-.094-.827a.723.723 0 0 0-.191-.148l-.137-.076l-1.733-.006c-1.395-.004-1.756.002-1.848.031m11.046-.014a.757.757 0 0 0-.353.214c-.137.185-.18.561-.094.826c.058.18.204.326.384.384c.122.04.321.045 1.81.045c1.429 0 1.692-.006 1.81-.041c.295-.088.439-.32.44-.707c0-.385-.147-.616-.452-.708c-.103-.031-.426-.037-1.794-.035c-.918.002-1.706.012-1.751.022m-6.892 3.004c-.123.057-.333.254-1.335 1.259c-.921.923-1.202 1.221-1.247 1.319a.617.617 0 0 0 .001.518c.07.15.3.386.455.467c.157.082.39.081.553-.002c.167-.086 2.477-2.396 2.563-2.563a.648.648 0 0 0 .003-.551a1.26 1.26 0 0 0-.454-.446a.569.569 0 0 0-.539-.001m5.9-.016c-.158.072-.391.3-.472.462a.605.605 0 0 0-.012.525c.074.165 2.398 2.497 2.581 2.59c.259.133.525.068.793-.194c.264-.258.334-.538.2-.799c-.093-.183-2.425-2.507-2.59-2.581a.638.638 0 0 0-.5-.003m-3.008 1.011a.768.768 0 0 0-.353.215c-.138.186-.139.199-.139 1.997c0 1.432.006 1.695.041 1.813c.088.295.321.439.706.439c.385 0 .618-.144.706-.439c.062-.212.061-3.427-.002-3.612a.528.528 0 0 0-.284-.344c-.11-.06-.174-.075-.363-.082a1.537 1.537 0 0 0-.312.013"},null,-1),He=[Ue];function Ke(u,l){return r(),T("svg",We,[...He])}const Xe={name:"nonicons-loading16",render:Ke},Je={class:"inline-block",viewBox:"0 0 24 24",width:"1em",height:"1em"},Qe=_("path",{fill:"currentColor",d:"m10.6 16.6l7.05-7.05l-1.4-1.4l-5.65 5.65l-2.85-2.85l-1.4 1.4zM12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22"},null,-1),Ye=[Qe];function Ze(u,l){return r(),T("svg",Je,[...Ye])}const Ge={name:"material-symbols-check-circle",render:Ze};function le(u,l){return ne({url:"/job/log/list",method:"get",params:u,signal:l==null?void 0:l.signal})}function et(u){return ne({url:"/retry-task-log/message/list",method:"get",params:u})}const tt={class:"flex-center"},lt={class:"ml-6px"},nt={class:"flex-center gap-8px"},ot={class:"flex-center"},at={key:0,class:"empty-height flex-center"},st={class:"flex items-center"},it={class:"flex-center gap-8px"},rt={key:0,class:"h-full flex-center"},ct=H({name:"LogDrawer",__name:"log-drawer",props:ce({title:{default:void 0},drawer:{type:Boolean,default:!0},type:{default:"job"},taskData:{default:void 0},modelValue:{default:()=>[]}},{show:{type:Boolean,default:!1},showModifiers:{}}),emits:["update:show"],setup(u){const l=u,f=ue(u,"show"),m=g(!1),S=g(!0),C=g([]),N=g(),b=g(1),p=g([]),$=g();let i=new AbortController;const a=g(!0);let k="0",x=0;const K=()=>{a.value=!0,clearTimeout($.value),$.value=void 0},P=()=>{a.value||i.abort(),K(),k="0",x=0,p.value=[]};async function B(){clearTimeout($.value);let n=null,e;if(l.type==="job"){const c=l.taskData,{data:o,error:v}=await le({taskBatchId:c.taskBatchId,jobId:c.jobId,taskId:c.id,startId:k,fromIndex:x,size:50},i);n=o,e=v}if(l.type==="retry"){const c=l.taskData,{data:o,error:v}=await et({groupName:c.groupName,uniqueId:c.uniqueId,startId:k,fromIndex:x,size:50});n=o,e=v}!e&&n?(a.value=n.finished||b.value===0,k=n.nextStartId,x=n.fromIndex,n.message&&(p.value.push(...n.message),p.value.sort((c,o)=>Number.parseInt(c.time_stamp,10)-Number.parseInt(o.time_stamp,10)).forEach((c,o)=>c.index=o)),fe(()=>{var c;m.value&&((c=N.value)==null||c.scrollTo({position:"bottom",debounce:!0}))}),!a.value&&b.value!==0&&($.value=setTimeout(B,b.value*1e3)),a.value&&b.value!==0&&setTimeout(()=>{X()},5*1e3)):(e==null?void 0:e.code)!=="ERR_CANCELED"&&P()}async function X(){if(clearTimeout($.value),l.type==="job"&&b.value!==0){const n=l.taskData,{data:e,error:c}=await le({taskBatchId:n.taskBatchId,jobId:n.jobId,taskId:n.id,startId:k,fromIndex:x,size:50},i);if(!c&&e){if(e.finished){$.value=setTimeout(X,5*1e3);return}await B()}}}de(()=>{P()}),_e(()=>f.value,async n=>{n&&l.modelValue&&(p.value=[...l.modelValue]),(n||!l.drawer)&&l.type&&l.taskData&&(a.value=!1,i=new AbortController,await B()),!n&&l.drawer&&P()},{immediate:!0});function oe(n){var D,F,V,q,E,y,Q,Y;const e=new Date(Number.parseInt(n==null?void 0:n.toString(),10)),c=e.getFullYear(),o=(e.getMonth()+1).toString().length===1?`0${e.getMonth()+1}`:(e.getMonth()+1).toString(),v=((D=e.getDate())==null?void 0:D.toString().length)===1?`0${e.getDate()}`:(F=e.getDate())==null?void 0:F.toString(),I=((V=e.getHours())==null?void 0:V.toString().length)===1?`0${e.getHours()}`:(q=e.getHours())==null?void 0:q.toString(),j=((E=e.getMinutes())==null?void 0:E.toString().length)===1?`0${e.getMinutes()}`:(y=e.getMinutes())==null?void 0:y.toString(),R=((Q=e.getSeconds())==null?void 0:Q.toString().length)===1?`0${e.getSeconds()}`:(Y=e.getSeconds())==null?void 0:Y.toString();return`${c}-${o}-${v} ${I}:${j}:${R}.${e.getMilliseconds()}`}const ae=me();function se(){let n;l.type==="job"&&(n={type:l.type,taskBatchId:l.taskData.taskBatchId,jobId:l.taskData.jobId,taskId:l.taskData.id}),l.type==="retry"&&(n={type:l.type,groupName:l.taskData.groupName,uniqueId:l.taskData.uniqueId});const e=ae.resolve({path:"/log",query:n});window.open(e.href)}const M=async n=>{if(n===-1){a.value&&(a.value=!1,await B());return}if(b.value=n,n===0){K();return}a.value=!1,await B()},L=g([{label:"Off",key:0},{label:"Auto(1s)",key:1},{label:"5s",key:5},{label:"10s",key:10},{label:"30s",key:30},{label:"1m",key:60},{label:"5m",key:300}]),J=H({setup(){if(a.value&&p.value.length===0)return()=>t(U,{class:"h-full flex-center",size:"huge"},null);const n=o=>{const v=o.throwable;if(!v)return t(te,null,null);const I=v.match(/^.+/m);if(!I)return t(te,null,null);const j=v.replace(/^.+(\n|$)/m,"");return t(Ie,{title:I[0],name:o.index},{default:()=>[`${j}`]})},e=o=>{C.value=o},c=()=>{C.value=[]};return()=>t("code",{class:"snail-log"},[t($e,{accordion:!0,"expanded-names":C.value,"onUpdate:expanded-names":o=>C.value=o,"on-update:expanded-names":e},{default:()=>[t(Te,{ref:N,class:"virtual-list",itemSize:85,"item-resizable":!0,"padding-bottom":16,items:p.value,"scrollbar-props":{xScrollable:!0},"on-resize":c},{default:({item:o})=>t("pre",{key:o.index,class:"min-h-85px min-w-full"},[t("div",null,[t("span",{class:"log-hljs-time inline-block"},[oe(o.time_stamp)]),t("span",{class:`log-hljs-level-${o.level} ml-12px mr-12px inline-block`},[`${o.level}`]),t("span",{class:"log-hljs-thread mr-12px inline-block"},[`[${o.host}:${o.port}]`]),t("span",{class:"log-hljs-thread mr-12px inline-block"},[`[${o.thread}]`])]),t("div",{class:"log-hljs-location"},[`${o.location}: `]),t("div",{class:"pl-6px"},[w("- "),`${o.message}`]),t("div",null,[n(o)]),t(ve,null,null)])})]})])}});return(n,e)=>{const c=Ge,o=ge,v=Xe,I=Pe,j=be,R=Ve,D=Ne,F=ye,V=ke,q=xe,E=we;return n.drawer?(r(),d(E,{key:0,show:f.value,"onUpdate:show":e[3]||(e[3]=y=>f.value=y),width:S.value?"100%":"50%","display-directive":"if","auto-focus":!1},{default:s(()=>[t(q,{closable:""},{header:s(()=>[_("div",{class:pe(["flex items-center justify-between",`tool-header${S.value?"-full":""}`])},[_("div",tt,[a.value?(r(),d(o,{key:0},{trigger:s(()=>[t(c,{class:"text-20px color-success"})]),default:s(()=>[w(" 日志加载完成 ")]),_:1})):(r(),d(o,{key:1},{trigger:s(()=>[t(h(A),{size:"small"},{icon:s(()=>[t(v)]),_:1})]),default:s(()=>[w(" 日志正在加载 ")]),_:1})),_("span",lt,W(n.title),1),t(h(G),{trigger:"hover",options:L.value,width:"trigger",onSelect:M},{default:s(()=>[t(o,{placement:"right"},{trigger:s(()=>[t(h(ee),{dashed:"",class:"ml-16px w-136px",onClick:e[0]||(e[0]=y=>M(-1))},{icon:s(()=>[_("div",nt,[t(I,{class:"text-18px"}),w(" "+W(L.value.filter(y=>y.key===b.value)[0].label)+" ",1),t(j,{icon:"material-symbols:expand-more-rounded"})])]),_:1})]),default:s(()=>[w(" 自动刷新频率 ")]),_:1})]),_:1},8,["options"])]),_("div",ot,[t(O,{size:"tiny","tooltip-content":m.value?"关闭自动滚动":"开启自动滚动",onClick:e[1]||(e[1]=()=>m.value=!m.value)},{default:s(()=>[m.value?(r(),d(R,{key:0})):(r(),d(D,{key:1}))]),_:1},8,["tooltip-content"]),t(O,{size:"tiny",icon:"hugeicons:share-01","tooltip-content":"在新标签页打开",class:"ml-6px",onClick:se}),t(O,{size:"tiny","tooltip-content":S.value?"半屏":"全屏",onClick:e[2]||(e[2]=()=>S.value=!S.value)},{default:s(()=>[S.value?(r(),d(F,{key:0})):(r(),d(V,{key:1}))]),_:1},8,["tooltip-content"])])],2)]),default:s(()=>[p.value.length===0?(r(),T("div",at,[p.value.length===0&&a.value?(r(),d(h(U),{key:0})):z("",!0),p.value.length===0&&!a.value?(r(),d(h(A),{key:1})):z("",!0)])):z("",!0),p.value.length>0?(r(),d(h(J),{key:1})):z("",!0)]),_:1})]),_:1},8,["show","width"])):(r(),d(h(he),{key:1,bordered:!1,title:n.title,size:"small",class:"h-full sm:flex-1-hidden card-wrapper"},{"header-extra":s(()=>[_("div",st,[t(h(G),{trigger:"hover",options:L.value,width:"trigger",onSelect:M},{default:s(()=>[t(o,{placement:"right"},{trigger:s(()=>[t(h(ee),{dashed:"",class:"mx-12px w-136px",onClick:e[4]||(e[4]=y=>M(-1))},{icon:s(()=>[_("div",it,[t(I,{class:"text-18px"}),w(" "+W(L.value.filter(y=>y.key===b.value)[0].label)+" ",1),t(j,{icon:"material-symbols:expand-more-rounded"})])]),_:1})]),default:s(()=>[w(" 自动刷新频率 ")]),_:1})]),_:1},8,["options"]),t(O,{size:"tiny",class:"mr-12px","tooltip-content":m.value?"关闭自动滚动":"开启自动滚动",onClick:e[5]||(e[5]=()=>m.value=!m.value)},{default:s(()=>[m.value?(r(),d(R,{key:0})):(r(),d(D,{key:1}))]),_:1},8,["tooltip-content"]),a.value?(r(),d(o,{key:0},{trigger:s(()=>[t(c,{class:"text-20px color-success"})]),default:s(()=>[w(" 日志加载完成 ")]),_:1})):(r(),d(o,{key:1},{trigger:s(()=>[t(h(A),{size:"small"},{icon:s(()=>[t(v)]),_:1})]),default:s(()=>[w(" 日志正在加载 ")]),_:1}))])]),default:s(()=>[p.value.length===0?(r(),T("div",rt,[p.value.length===0&&a.value?(r(),d(h(U),{key:0})):z("",!0),p.value.length===0&&!a.value?(r(),d(h(A),{key:1})):z("",!0)])):z("",!0),t(h(J))]),_:1},8,["title"]))}}}),_t=Se(ct,[["__scopeId","data-v-05ada7e9"]]);export{_t as _,Pe as a,Ge as b,Xe as c,et as f};
|