You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
3.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{n as e}from"./axios-CiYFffbI.js";import{I as t,N as n,O as r,V as i,Y as a,_ as o,d as s,f as c,i as l,it as u,kt as d,l as f,p,q as m,u as h,ut as g,v as _,y as v,z as y}from"./runtime-core.esm-bundler-CnFWH3R5.js";import{n as b}from"./http-LCi9aT1G.js";import{u as x}from"./index-B07osdMA.js";import{t as S}from"./datetime-DLy52ZIc.js";var C={key:0,class:`system-logs-pre`},w={key:1,class:`system-logs-empty`},T=x(v({__name:`SystemLogs`,setup(v){let x=u(!1),T=u(``),E=u(400),D=u(``),O=u([]),k=u([]),A=u(null),j=u(null),M=u(!1),N=f(()=>{let e=T.value.trim().toLowerCase();return e?k.value.filter(t=>t.toLowerCase().includes(e)):k.value});function P(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}async function F(){await r();let e=j.value;e&&(e.scrollTop=e.scrollHeight)}async function I(){x.value=!0,A.value=null;try{let{data:e}=await b.get(`/system-logs`,{params:{file:D.value||void 0,lines:E.value}});O.value=e.files??[],M.value=!0,D.value=e.file??``,await r(),M.value=!1,k.value=e.lines??[],A.value=e.error??null,await F()}catch(t){e.error(t?.response?.data?.message??`加载系统日志失败`),k.value=[],M.value=!1}finally{x.value=!1}}return m(D,()=>{M.value||I()}),n(I),(e,n)=>{let r=i(`a-alert`),u=i(`a-option`),f=i(`a-select`),m=i(`a-input-number`),v=i(`a-input`),b=i(`a-button`),k=i(`a-space`),M=i(`a-spin`),F=i(`a-card`);return t(),s(F,{title:`系统设置 / 系统日志`},{default:a(()=>[_(r,{type:`warning`,style:{"margin-bottom":`12px`}},{default:a(()=>[...n[3]||=[o(` 展示服务器 `,-1),h(`code`,null,`storage/logs`,-1),o(` 下 Laravel 应用日志文件尾部(按行)。仅超级管理员可访问;请勿将日志内容外传。 `,-1)]]),_:1}),_(k,{wrap:``,size:12,style:{"margin-bottom":`12px`}},{default:a(()=>[n[5]||=h(`span`,{class:`system-logs-tool-label`},`日志文件`,-1),_(f,{modelValue:D.value,"onUpdate:modelValue":n[0]||=e=>D.value=e,"allow-clear":``,placeholder:`选择文件`,style:{width:`260px`},loading:x.value},{default:a(()=>[(t(!0),p(l,null,y(O.value,e=>(t(),s(u,{key:e.name,value:e.name},{default:a(()=>[o(d(e.name)+``+d(P(e.size_bytes))+``+d(g(S)(e.modified_at))+` `,1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`modelValue`,`loading`]),n[6]||=h(`span`,{class:`system-logs-tool-label`},`尾部行数`,-1),_(m,{modelValue:E.value,"onUpdate:modelValue":n[1]||=e=>E.value=e,min:50,max:5e3,step:50,style:{width:`120px`}},null,8,[`modelValue`]),_(v,{modelValue:T.value,"onUpdate:modelValue":n[2]||=e=>T.value=e,placeholder:`在行内筛选关键字`,"allow-clear":``,style:{width:`220px`}},null,8,[`modelValue`]),_(b,{type:`primary`,loading:x.value,onClick:I},{default:a(()=>[...n[4]||=[o(`刷新`,-1)]]),_:1},8,[`loading`])]),_:1}),A.value?(t(),s(r,{key:0,type:`error`,style:{"margin-bottom":`8px`}},{default:a(()=>[o(d(A.value),1)]),_:1})):c(``,!0),h(`div`,{ref_key:`scrollEl`,ref:j,class:`system-logs-panel`,tabindex:`0`,role:`region`,"aria-label":`日志内容`},[_(M,{loading:x.value,style:{display:`block`,"min-height":`120px`}},{default:a(()=>[N.value.length?(t(),p(`pre`,C,d(N.value.join(`
`)),1)):x.value?c(``,!0):(t(),p(`div`,w,`暂无日志内容或无权限读取文件。`))]),_:1},8,[`loading`])],512)]),_:1})}}}),[[`__scopeId`,`data-v-00758b3f`]]);export{T as default};