import{a as l,r as a,w as j,j as s,z as m,v as w,B as v}from"./index-BT6xGZJ2.js";import{u as z}from"./index-B10G697B.js";import{C as F}from"./index-BLVx9eCn.js";import{T as u}from"./index-Bw31C-LM.js";const A=async e=>await l.get("/file-operation/read-file",{params:{file_path:e}}),b=async(e,o=0)=>await l.get("/file-operation/read-log-file",{params:{file_path:e,offset:o}}),k=async(e,o)=>await l.post("/file-operation/write-file",{file_path:e,content:o}),{Text:g}=w,B=({file_path:e})=>{var f;a.useEffect(()=>{console.log("fileKey",e),e&&d(e)},[e]);const{messageApi:o}=j(),i=a.useRef(0),[t,h]=a.useState([]),d=async(r,y=!1)=>{const x=await b(r);i.current=x.data.offset,h(x.data.content),y&&o.success(`日志加载成功: ${r}`)},c=a.useRef(null),n=z({count:t.length,getScrollElement:()=>c.current,estimateSize:()=>30,overscan:10});a.useEffect(()=>{(t==null?void 0:t.length)>0&&n.scrollToIndex(t.length-1,{align:"end",behavior:"smooth"})},[t==null?void 0:t.length]);const p=n.getVirtualItems();return s.jsx(F,{size:"small",extra:s.jsx(v,{size:"small",color:"cyan",variant:"solid",onClick:()=>{d(e)},children:"刷新日志"}),title:s.jsxs(m,{gap:"small",wrap:"wrap",children:[s.jsxs(u,{color:"blue",children:["文件: ",e]}),s.jsxs(u,{color:"purple",children:["偏移量: ",i.current]})]}),bodyStyle:{padding:0},children:s.jsx("div",{ref:c,style:{height:400,overflowY:"auto",fontFamily:"monospace",backgroundColor:"#1e1e1e",color:"#d4d4d4",padding:"0 12px"},children:s.jsx("div",{style:{height:n.getTotalSize(),width:"100%",position:"relative"},children:s.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${((f=p[0])==null?void 0:f.start)??0}px)`},children:p.map(r=>s.jsx("div",{"data-index":r.index,ref:n.measureElement,style:{padding:"4px 0",borderBottom:"1px solid #333"},children:s.jsxs(m,{gap:"middle",children:[s.jsxs(g,{type:"secondary",style:{width:60,color:"#d4d4d4"},children:["#",r.index+1]}),s.jsx(g,{style:{whiteSpace:"pre-wrap",color:"#d4d4d4"},children:t[r.index]})]})},r.key))})})})})};export{B as L,A as r,k as w};
