filecat
Version:
FileCat Server Manager
2 lines • 14.1 kB
JavaScript
/*! For license information please see 502.ce9ef50072a0c03ef10c.js.LICENSE.txt */
;(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[502],{2502:(t,e,n)=>{n.r(e),n.d(e,{default:()=>M});var r=n(6540),o=n(4238),i=n(4944),c=n(7444),a=n(6417),l=n(7952),s=n(5997),u=n(7022),f=n(4289),p=n(2042),h=n(3033),d=n(2389),_=n(4694),v=n(447);function y(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=E(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return c=t.done,t},e:function(t){a=!0,i=t},f:function(){try{c||null==n.return||n.return()}finally{if(a)throw i}}}}function m(t){return function(t){if(Array.isArray(t))return A(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||E(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=r&&r.prototype instanceof a?r:a,s=Object.create(l.prototype);return x(s,"_invoke",function(n,r,o){var i,a,l,s=0,u=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,a=0,l=t,p.n=n,c}};function h(n,r){for(a=n,l=r,e=0;!f&&s&&!o&&e<u.length;e++){var o,i=u[e],h=p.p,d=i[2];n>3?(o=d===r)&&(l=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(a=0,p.v=r,p.n=i[1]):h<d&&(o=n<3||i[0]>r||r>d)&&(i[4]=n,i[5]=r,p.n=d,a=0))}if(o||n>1)return c;throw f=!0,r}return function(o,u,d){if(s>1)throw TypeError("Generator is already running");for(f&&1===u&&h(u,d),a=u,l=d;(e=a<2?t:l)||!f;){i||(a?a<3?(a>1&&(p.n=-1),h(a,l)):p.n=l:p.v=l);try{if(s=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(f=p.n<0)?l:n.call(r,p))!==c)break}catch(e){i=t,a=1,l=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var c={};function a(){}function l(){}function s(){}e=Object.getPrototypeOf;var u=[][r]?e(e([][r]())):(x(e={},r,function(){return this}),e),f=s.prototype=a.prototype=Object.create(u);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,x(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return l.prototype=s,x(f,"constructor",s),x(s,"constructor",l),l.displayName="GeneratorFunction",x(s,o,"GeneratorFunction"),x(f),x(f,o,"Generator"),x(f,r,function(){return this}),x(f,"toString",function(){return"[object Generator]"}),(g=function(){return{w:i,m:p}})()}function x(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}x=function(t,e,n,r){function i(e,n){x(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},x(t,e,n,r)}function b(t,e,n,r,o,i,c){try{var a=t[i](c),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(r,o)}function w(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function c(t){b(i,r,o,c,a,"next",t)}function a(t){b(i,r,o,c,a,"throw",t)}c(void 0)})}}function k(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,c,a=[],l=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(t){s=!0,o=t}finally{try{if(!l&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw o}}return a}}(t,e)||E(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e){if(t){if("string"==typeof t)return A(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,e):void 0}}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var S,T=300,C=!1,I=0,j=!0,H=[],O=-1,z=[];function M(t){var e=k((0,c.L4)(a.A.log_viewer),2),n=e[0],x=e[1],b=(0,r.useRef)(null),E=k((0,r.useState)(0),2),A=E[0],M=E[1],G=k((0,r.useState)(100),2),L=G[0],N=G[1],K=k((0,r.useState)(!1),2),P=K[0],D=K[1],F=k((0,r.useState)(""),2),$=F[0],q=F[1],R=k((0,r.useState)(0),2),B=R[0],W=R[1],Y=k((0,r.useState)(0),2),Z=Y[0],U=Y[1],X=k((0,r.useState)(0),2),J=(X[0],X[1]),Q=(0,d.Bd)().t,V=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0,i=document.createElement("div");return-1===O?i.textContent=t:i.innerHTML=t,i.style.whiteSpace="pre-wrap",i.style.overflowWrap="break-word",i.setAttribute("position","".concat(e)),i.setAttribute("start_position","".concat(n)),r?(b.current.insertBefore(i,o),H.unshift(i)):(b.current.appendChild(i),H.push(i)),i},tt=function(t){var e=(0,_.I)(H,function(e){return e===t});e&&b.current.removeChild(e)},et=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t){var o=Array.isArray(t)?t:t.split("\n");if(r){for(var i,c=0;c<o.length;c++)i=V(o[c],e[c],n[c],!0,0===c?b.current.firstChild:i);if(H.length>T)for(var a=H.length-1;a>=T;)tt(H[H.length-1]),a--}else{for(var l=0;l<o.length;l++)V(o[l],e[l],n[l]);if(H.length>T)for(var s=H.length-T;s>0;)tt(H[0]),s--}}},nt=function(){var t=w(g().m(function t(){var e,r,c,a,l;return g().w(function(t){for(;;)switch(t.n){case 0:return S.encoding=n.encoding,S.context="",t.n=1,i.ws.sendData(o.HK.log_viewer,S);case 1:if(e=t.v){if(r=e.context,S=r,r.find_back_enter_index&&r.context_list.length>0)for(c=0;c<r.context_list.length;c++)a=new RegExp(r.query_text,"g"),r.context_list[c]=r.context_list[c].replace(a,'<span style="color: blue;">'.concat(r.query_text,"</span>"));S.find_back_enter_index=!1,et(r.context_list,r.context_position_list,r.context_start_position_list,S.back),S.context_list.length>0&&(S.back&&H.length>0?(S.context_list.length>H.length?M(Math.floor(100*parseInt(H[S.context_list.length-H.length].getAttribute("position"))/S.max_size)):M(Math.floor(100*parseInt(H[H.length-S.context_list.length].getAttribute("position"))/S.max_size)),j=!1):M(Math.floor(100*(null!==(l=S.context_position_list[S.context_position_list.length-1])&&void 0!==l?l:0)/S.max_size))),b.current.clientHeight===b.current.scrollHeight&&rt(S.max_size)}case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),rt=function(t){C||(C=!0,M(100),i.ws.addMsg(o.HK.log_viewer_watch,function(t){var e=t.context;e&&(S=e,et(e.context_list,e.context_position_list,e.context_start_position_list,!1),b.current.scrollTop=b.current.scrollHeight)}),S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.position=t,i.ws.sendData(o.HK.log_viewer_watch,S),D(!0))},ot=function(){C&&(C=!1,i.ws.unConnect(),D(!1))},it=function(){var t=w(g().m(function t(){var e,r;return g().w(function(t){for(;;)switch(t.n){case 0:return e=function(){var t=w(g().m(function t(){var e,n,r;return g().w(function(t){for(;;)switch(t.n){case 0:if(!(e=b.current)){t.n=7;break}if(I>e.scrollTop&&ot(),!C){t.n=1;break}return I=e.scrollTop,t.a(2);case 1:if(!(I<e.scrollTop&&H.length>0&&e.scrollTop+e.clientHeight+500>=e.scrollHeight)){t.n=4;break}if(!((n=parseInt(H[H.length-1].getAttribute("position")))>=S.max_size)){t.n=2;break}return rt(n),t.a(2);case 2:return S.line=20,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.back=!1,S.position=n,t.n=3,nt();case 3:t.n=6;break;case 4:if(!(I>e.scrollTop&&H.length>0&&e.scrollTop-300<=0)){t.n=6;break}if(!((r=parseInt(H[0].getAttribute("start_position")))<=0)){t.n=5;break}return j||(j=!0,(0,p.N9)("到达顶部")),I=e.scrollTop,t.a(2);case 5:return S.line=10,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.back=!0,S.position=r,t.n=6,nt();case 6:I=e.scrollTop;case 7:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),b.current.addEventListener("scroll",e),r=function(t){var e=b.current;if(e){t.preventDefault();t.deltaY>0?e.scrollTop+=20:e.scrollTop-=20}},b.current.addEventListener("wheel",r,{passive:!1}),D(!1),W(0),U(0),q(""),C=!1,J(0),I=0,z=[],O=-1,H=[],(S=new u.d2).line=T,S.path="".concat((0,f.GG)("file",(0,f.vX)())).concat(n.fileName),S.token=localStorage.getItem("token"),t.n=1,nt();case 1:i.ws.addMsg(o.HK.search_file_progress,function(t){try{W(parseInt(t.context))}catch(t){(0,p.zN)(t.message)}}),i.ws.addMsg(o.HK.search_file_index,function(t){try{var e;(e=z).push.apply(e,m(t.context)),J(t.context.length)}catch(t){(0,p.zN)(t.message)}});case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),ct=function(){var t=w(g().m(function t(){return g().w(function(t){for(;;)switch(t.n){case 0:return b.current&&b.current.remove(),t.n=1,i.ws.unConnect();case 1:H=[];case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}();if((0,r.useEffect)(function(){n.show?it():ct()},[n]),(0,r.useEffect)(function(){return function(){ct()}},[]),n.show){var at=function(){var t=w(g().m(function t(){var e,n,r,o,i;return g().w(function(t){for(;;)switch(t.p=t.n){case 0:if(S.line=T,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=0,t.p=1,!((e=parseInt(L))>100||e<0)){t.n=2;break}throw(0,p.zN)("范围在0-100"),"超过最大范围";case 2:n=y(H);try{for(n.s();!(r=n.n()).done;)o=r.value,b.current.removeChild(o)}catch(t){n.e(t)}finally{n.f()}H=[],t.n=4;break;case 3:return t.p=3,i=t.v,(0,p.N9)(i),t.a(2);case 4:return S.back=e>=100,S.position=Math.floor(S.max_size*(e/100)),t.n=5,nt();case 5:return t.a(2)}},t,null,[[1,3]])}));return function(){return t.apply(this,arguments)}}(),lt=function(){var t=w(g().m(function t(){var e,n,r;return g().w(function(t){for(;;)switch(t.n){case 0:if(!C){t.n=1;break}return t.a(2);case 1:S.line=T,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=y(H);try{for(e.s();!(n=e.n()).done;)r=n.value,b.current.removeChild(r)}catch(t){e.e(t)}finally{e.f()}return H=[],S.back=!0,S.position=S.max_size,t.n=2,nt();case 2:b.current.scrollTop=b.current.scrollHeight,rt(S.max_size);case 3:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),st=function(){var t=w(g().m(function t(){return g().w(function(t){for(;;)switch(t.n){case 0:if($){t.n=1;break}return t.a(2);case 1:W(.1),U(0),J(0),O=-1,z=[],S.query_text=$,S.encoding=n.encoding,i.ws.sendData(o.HK.search_file,S);case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),ut=function(){var t=w(g().m(function t(){var e,n,r,o;return g().w(function(t){for(;;)switch(t.n){case 0:if(0!==z.length){t.n=1;break}return t.a(2);case 1:S.line=T,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=y(H);try{for(e.s();!(n=e.n()).done;)r=n.value,b.current.removeChild(r)}catch(t){e.e(t)}finally{e.f()}return H=[],o=O+1>=z.length?0:O+1,U(o+1),O=o,S.find_back_enter_index=!0,S.back=!1,S.position=z[O],t.n=2,nt();case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}(),ft=function(){var t=w(g().m(function t(){var e,n,r,o;return g().w(function(t){for(;;)switch(t.n){case 0:if(0!==z.length){t.n=1;break}return t.a(2);case 1:S.line=T,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=y(H);try{for(e.s();!(n=e.n()).done;)r=n.value,b.current.removeChild(r)}catch(t){e.e(t)}finally{e.f()}return H=[],o=O-1<0?z.length-1:O-1,U(o+1),O=o,S.back=!1,S.find_back_enter_index=!0,S.position=z[O],t.n=2,nt();case 2:return t.a(2)}},t)}));return function(){return t.apply(this,arguments)}}();return r.createElement("div",{id:"editor-container"},r.createElement(l.A,{ignore_tags:!0,left_children:[r.createElement(s.rA,{key:1,title:Q("取消"),icon:"close",onClick:function(){x({show:!1})}}),r.createElement("div",{key:2,style:{width:"4rem"}},r.createElement(v.WA,{context:n.fileName})),r.createElement(r.Fragment,{key:3}," ",r.createElement(h.$Z,{handleEnterPress:st,placeholder:Q("回车搜索整个文件"),icon:"search",value:$,handleInputChange:function(t){q(t)},max_width:"25em"})),$&&r.createElement("div",{key:5,style:{paddingLeft:"1.5rem",cursor:"pointer"},onClick:ut},"↓"),$&&r.createElement("div",{key:6,style:{paddingLeft:"1.5rem",cursor:"pointer"},onClick:ft},"↑"),$&&r.createElement("div",{key:7,style:{paddingLeft:"1.5rem"}},Z,"/",z.length),$&&r.createElement("div",{key:8,style:{paddingLeft:"1.5rem"}},"搜索进度$",B,"%"),0!==B&&100!==B&&r.createElement(s.rA,{key:4,title:Q("取消"),icon:"cancel",onClick:function(){i.ws.sendData(o.HK.search_file_cancel,{}),q(""),W(0)}})]},r.createElement("span",{style:{paddingRight:".5rem"}},n.encoding),P&&r.createElement("span",{style:{color:"var(--icon-green)",whiteSpace:"pre"}},"正在实时监听 "),r.createElement("span",null,"当前加载进度",A),r.createElement(h.$Z,{max_width:"10rem",placeholder:Q("跳转进度"),icon:"percent",value:L,handleInputChange:function(t){N(t)}}),r.createElement(s.rA,{icon:"play_arrow",title:Q("跳转进度"),onClick:at}),r.createElement(s.rA,{icon:"text_rotate_vertical",title:Q("滑动到文件最底部,实时输出"),onClick:lt})),r.createElement("div",{style:{height:"100%"}},r.createElement("div",{ref:b,style:{overflowY:"auto",height:"100%"}})))}}}}]);