import{l as a,$ as e,x as l,a0 as t,M as s,a3 as n,u as o,ai as i,q as u,a1 as r,a2 as c,_ as p}from"./utils-lib.js?v=20260328163632";import{B as d}from"./index118.js?v=20260328163632";import{g,a as m}from"./logs.js?v=20260328163632";import{r as v,c as h,k as y,O as x,o as f,J as b,V as _,W as k,X as L,Y as w,N as j,H as C,F as S,L as V,a3 as z,Z as A,_ as B,K as q,j as H,a1 as O}from"./base-lib.js?v=20260328163632";import{aw as N,au as P,B as R}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";const U=v(""),W=v(""),E=v([]),F=v(""),I=v({}),J=v(""),K=v("operationLog"),M=h((()=>["runLog","errorLog"].includes(K.value))),T=v({count:0,limit:200,log_end:!0,maxPage:200,page:1}),X=v({page:1,pageSize:20,itemCount:0,pageSlot:5}),Y=async()=>{await l({request:t({table:"sites",search:U.value,limit:999999}),success:a=>{var e;E.value=Array.isArray(null==(e=a.data)?void 0:e.data)?a.data.data:[]}})},Z=a=>{K.value=a,"webLog"!==a&&(oa(),G())},$=a=>{F.value=a.id.toString(),I.value=a,oa(),na(),G()},D=async()=>{J.value="",await G(),s.success(a("刷新成功"))},G=async(e="")=>{if(!E.value.length)return;""===e&&(T.value.page=1);const{page:s,limit:n}=T.value,o={operationLog:t,runLog:g,errorLog:m,webLog:g},i={siteid:Number(F.value),p:s,limit:n,search:W.value},u={operationLog:{table:"logs",search_type:"网站管理",search:I.value.name,p:X.value.page,limit:X.value.pageSize}}[K.value]||i;l({loading:a("正在获取日志，请稍后..."),request:o[K.value](u),success:a=>{var l;if(Array.isArray(null==(l=a.data)?void 0:l.data))if(M.value){const{data:l,page:t}=a.data;J.value=e+l.join("\n"),T.value=t}else aa.value.data=a.data.data,X.value.itemCount=a.data.page.total}})},Q=()=>{T.value.log_end||(T.value.page++,G(J.value+"\n"))},aa=v({columns:[{title:a("用户"),key:"username",width:180},{title:a("操作类型"),key:"type",width:100},{title:a("日志"),key:"log"},{title:a("操作时间"),key:"addtime",width:150}],data:[]}),[ea,la]=e(aa),[ta]=n(X),sa=async()=>{ia(),await Y(),E.value.length&&$(E.value[0])},na=()=>{aa.value.data=[],Object.assign(X.value,{page:1,pageSize:20,itemCount:0,pageSlot:5})},oa=()=>{W.value="",J.value="",Object.assign(T.value,{count:0,limit:200,log_end:!0,maxPage:200,page:1})},ia=()=>{U.value="",F.value="",K.value="operationLog",oa(),na()},ua={class:"flex"},ra={class:"w-240px"},ca=["onClick","tabindex"],pa={key:1,class:"menu p-[20px] bg-[#f1f1f120] !h-[80%]"},da={class:"flex-1 pl-16px"},ga={class:"text-14px text-[var(--text-color-2)]"},ma=p(y({__name:"index",setup(e,{expose:l}){const{mainHeight:t}=o(),{BtTabs:s,tabs:n}=i({type:"card",value:K,options:[{tab:a("网站操作日志"),name:"operationLog",render:()=>x("span",null,null)},{tab:a("网站运行日志"),name:"runLog",render:()=>x("span",null,null)},{tab:a("网站错误日志"),name:"errorLog",render:()=>x("span",null,null)},{tab:a("WEB日志分析"),name:"webLog",render:()=>x("span",null,null)}]});return f(sa),b(ia),l({init:sa}),(e,l)=>{const n=N,o=R,i=P;return _(),k("div",ua,[L("div",ra,[x(w(u),{modelValue:w(U),"onUpdate:modelValue":l[0]||(l[0]=a=>j(U)?U.value=a:null),placeholder:w(a)("请搜索用户名"),class:"!w-full mb-8px",onSearch:w(Y)},null,8,["modelValue","placeholder","onSearch"]),w(E).length>0?(_(),k("div",{key:0,class:"menu",style:C("height:".concat(w(t)-180,"px"))},[(_(!0),k(S,null,V(w(E),((a,e)=>(_(),k("span",{onClick:e=>w($)(a),tabindex:e,key:e,class:q("menu-hover ".concat(String(a.id)===w(F)?"activeClass":""))},A(a.name)+" ["+A(a.ps)+"] ",11,ca)))),128))],4)):(_(),k("span",pa,[x(n,null,{icon:z((()=>l[3]||(l[3]=[L("i",{class:"svgtofont-empty !text-[4.8rem] text-#999"},null,-1)]))),default:z((()=>[H(A(w(a)("暂无数据")),1)])),_:1})]))]),L("div",da,[x(w(s),{class:"no-bg audit-log",onChange:w(Z)},null,8,["onChange"]),"webLog"===w(K)?(_(),k("div",{key:0,class:"flex items-center w-full justify-center",style:C("height:".concat(w(t)-220,"px"))},A(w(a)("暂不支持该功能！")),5)):(_(),k(S,{key:1},[x(i,{justify:"space-between"},{default:z((()=>[x(o,{type:"primary",onClick:w(D)},{default:z((()=>[H(A(w(a)("刷新日志")),1)])),_:1},8,["onClick"]),w(M)?(_(),B(w(u),{key:0,modelValue:w(W),"onUpdate:modelValue":l[1]||(l[1]=a=>j(W)?W.value=a:null),placeholder:w(a)("请搜索日志"),class:"!w-[220px]",onSearch:l[2]||(l[2]=()=>w(G)())},null,8,["modelValue","placeholder"])):O("",!0)])),_:1}),w(M)?(_(),B(d,{key:0,class:"mt-10px",content:w(J),autoScroll:!1,onLoad:w(Q),style:C("height:".concat(w(t)-220,"px"))},null,8,["content","onLoad","style"])):(_(),B(w(c),{key:1},{content:z((()=>[x(w(ea),{"max-height":w(t)-220},null,8,["max-height"])])),"footer-right":z((()=>[x(w(ta),{"show-size-picker":"","page-sizes":w(r)([10,20,50,100]),onRefresh:w(G)},{suffix:z((()=>[L("span",ga,A(w(a)("共 {0} 条",[w(X).itemCount||0])),1)])),_:1},8,["page-sizes","onRefresh"])])),_:1}))],64))])])}}}),[["__scopeId","data-v-051dbf44"]]);export{ma as default};
