import{d as A,u as Q,q,c as _,e as o,a,C as E,w as l,x as K,F as M,l as U,p as v,y as C,k as y,j,r as i,z as P,o as p,i as d,t as r}from"./index-CcdGGfCj.js";import{h as Z,a as G,_ as D}from"./http-CGjljVXL.js";import{_ as H}from"./PageHeader.vue_vue_type_script_setup_true_lang-ClDoYPHj.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";const O={class:"page-stack management-page"},R={class:"panel filter-bar"},W={class:"panel table-panel"},X={class:"column-label"},Y={class:"column-help"},ee={class:"column-label"},te={class:"column-help"},ae={key:0,class:"mobile-card-list"},oe=A({__name:"AuditLogsView",setup(ne){const V=Q(),g=y(!1),m=y([]),f=y(0),s=j({keyword:"",page:1,page_size:15}),z={create:"新建",batch_create:"批量新建",update:"修改",batch_update:"批量修改",toggle:"状态变更",delete:"删除",batch_delete:"批量删除",reorder:"调整顺序",generate:"生成",save:"保存",save_draft:"保存草稿",grant_points:"增加积分",password_changed:"修改密码",password_change_failed:"修改密码失败"},I={users:"用户","redemption-codes":"兑换码",styles:"风格",prompts:"提示词",channels:"渠道",models:"模型","admin-auth":"管理员账号"};async function c(){g.value=!0;try{const{data:n}=await Z.get("/audit-logs",{params:s});m.value=n.data.items,f.value=n.data.total}catch(n){const e=G(n);V.error(e.message,e.copyText)}finally{g.value=!1}}function L(){s.keyword="",s.page=1,c()}function b(n){return z[n]||n||"未知操作"}function w(n){return I[n]||n||"未知资源"}function k(n){return n?new Date(String(n)).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",hour12:!1}):"--"}return q(c),(n,e)=>{const T=i("el-input"),h=i("el-button"),u=i("el-table-column"),N=i("el-tag"),x=i("el-tooltip"),S=i("el-table"),B=i("el-empty"),F=i("el-pagination"),$=P("loading");return p(),_("div",O,[o(H,{title:"审计日志"}),a("section",R,[o(T,{modelValue:s.keyword,"onUpdate:modelValue":e[0]||(e[0]=t=>s.keyword=t),modelModifiers:{trim:!0},clearable:"",placeholder:"管理员、操作、资源、原因、对象 ID 或追踪 ID",onKeyup:e[1]||(e[1]=E(t=>{s.page=1,c()},["enter"]))},null,8,["modelValue"]),o(h,{type:"primary",onClick:e[2]||(e[2]=t=>{s.page=1,c()})},{default:l(()=>[...e[4]||(e[4]=[d("查询",-1)])]),_:1}),o(h,{onClick:L},{default:l(()=>[...e[5]||(e[5]=[d("重置",-1)])]),_:1})]),K((p(),_("section",W,[o(S,{class:"desktop-table",data:m.value},{default:l(()=>[o(u,{prop:"admin_username",label:"管理员","min-width":"120","show-overflow-tooltip":""}),o(u,{label:"操作","min-width":"120"},{default:l(({row:t})=>[o(N,{effect:"plain"},{default:l(()=>[d(r(b(t.action)),1)]),_:2},1024)]),_:1}),o(u,{label:"资源","min-width":"120"},{default:l(({row:t})=>[d(r(w(t.resource_type)),1)]),_:1}),o(u,{prop:"resource_id","min-width":"180","show-overflow-tooltip":""},{header:l(()=>[a("span",X,[e[6]||(e[6]=d(" 对象 ID ",-1)),o(x,{content:"被操作数据的唯一标识；即使对象改名或删除，仍可用它准确定位记录。",placement:"top"},{default:l(()=>[a("span",Y,[o(D,{name:"QuestionFilled"})])]),_:1})])]),_:1}),o(u,{prop:"reason",label:"操作原因","min-width":"180","show-overflow-tooltip":""},{default:l(({row:t})=>[d(r(t.reason||"--"),1)]),_:1}),o(u,{prop:"trace_id","min-width":"180","show-overflow-tooltip":""},{header:l(()=>[a("span",ee,[e[7]||(e[7]=d(" 请求追踪 ID ",-1)),o(x,{content:"本次请求的唯一追踪编号，用于在服务器日志中查找并关联同一次请求。",placement:"top"},{default:l(()=>[a("span",te,[o(D,{name:"QuestionFilled"})])]),_:1})])]),_:1}),o(u,{label:"操作时间","min-width":"180"},{default:l(({row:t})=>[d(r(k(t.created_at)),1)]),_:1})]),_:1},8,["data"]),m.value.length?(p(),_("div",ae,[(p(!0),_(M,null,U(m.value,t=>(p(),_("article",{key:t.id,class:"data-card"},[a("dl",null,[e[8]||(e[8]=a("dt",null,"管理员",-1)),a("dd",null,r(t.admin_username),1),e[9]||(e[9]=a("dt",null,"操作",-1)),a("dd",null,r(b(t.action)),1),e[10]||(e[10]=a("dt",null,"资源",-1)),a("dd",null,r(w(t.resource_type)),1),e[11]||(e[11]=a("dt",null,"对象 ID",-1)),a("dd",null,r(t.resource_id||"--"),1),e[12]||(e[12]=a("dt",null,"操作原因",-1)),a("dd",null,r(t.reason||"--"),1),e[13]||(e[13]=a("dt",null,"请求追踪 ID",-1)),a("dd",null,r(t.trace_id||"--"),1),e[14]||(e[14]=a("dt",null,"操作时间",-1)),a("dd",null,r(k(t.created_at)),1)])]))),128))])):v("",!0),!g.value&&!m.value.length?(p(),C(B,{key:1,description:"暂无审计日志"})):v("",!0),f.value>s.page_size?(p(),C(F,{key:2,"current-page":s.page,"onUpdate:currentPage":e[3]||(e[3]=t=>s.page=t),background:"",layout:"total,prev,pager,next",total:f.value,"page-size":s.page_size,onCurrentChange:c},null,8,["current-page","total","page-size"])):v("",!0)])),[[$,g.value]])])}}}),de=J(oe,[["__scopeId","data-v-965ad148"]]);export{de as default};
