1import{r as e,j as a}from"./vendor-react-DejgYtBM.js";import{u as t,Z as s,Y as l,ac as r,A as n,s as i,$ as o,w as c}from"./index-BeIIFw6E.js";import{z as d,f as m,j as p,i as u,m as x,E as g,J as h,K as _,B as j,D as f,o as w,M as v}from"./vendor-semi-D8d7bTtM.js";import{C as y}from"./CardTable-Cq0lqlnD.js";import{u as N}from"./useTableCompactMode-DWLN7NUj.js";import{ad as b,T as I,X as C,ae as z,y as S,af as T,S as k,K as P,ag as E,U as D}from"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";import"./useIsMobile-D_kfVI0u.js";const{Text:L,Title:M}=m,V=()=>{const{t:m}=t(),[M,V]=e.useState([]),[$,K]=e.useState(!0),[q,A]=e.useState(1),[O,R]=e.useState(s),[U,W]=e.useState(!1),[B,F]=e.useState(0),J=e.useRef(!1),[X,Y]=N("operationLog"),[Z,G]=e.useState(null),H=[{label:m("å
¨é¨"),value:""},{label:m("ç¨æ·ç®¡ç"),value:"user_management"},{label:m("æ¸ é管ç"),value:"channel_management"},{label:m("令ç管ç"),value:"token_management"},{label:m("ç³»ç»é
ç½®"),value:"system_config"},{label:m("å
æ¢ç 管ç"),value:"redemption_management"},{label:m("æ¥å¿ç®¡ç"),value:"log_management"},{label:m("å
¶ä»æä½"),value:"other"}],Q=[{label:m("å
¨é¨"),value:""},{label:m("ä¿®æ¹é¢åº¦"),value:"update_quota"},{label:m("ä¿®æ¹å¯ç "),value:"update_password"},{label:m("ä¿®æ¹è§è²"),value:"update_role"},{label:m("ä¿®æ¹ç¶æ"),value:"update_status"},{label:m("ä¿®æ¹ç¨æ·ä¿¡æ¯"),value:"update_profile"},{label:m("åå»ºç¨æ·"),value:"create_user"},{label:m("å é¤ç¨æ·"),value:"delete_user"},{label:m("管çç¨æ·"),value:"manage_user"},{label:m("é¢è§å¤äººè¿ç§»"),value:"preview_user_migration"},{label:m("æ§è¡å¤äººè¿ç§»"),value:"execute_user_migration"},{label:m("é¢è§å人è¿ç§»"),value:"preview_user_migration_single"},{label:m("æ§è¡å人è¿ç§»"),value:"execute_user_migration_single"},{label:m("åéè¿ç§»éç¥é®ä»¶"),value:"send_migration_emails"},{label:m("é¢è§ç¨æ·è¿ç§»åæ»"),value:"preview_user_migration_rollback"},{label:m("æ§è¡ç¨æ·è¿ç§»åæ»"),value:"execute_user_migration_rollback"},{label:m("åå»ºæ¸ é"),value:"create_channel"},{label:m("æ´æ°æ¸ é"),value:"update_channel"},{label:m("å 餿¸ é"),value:"delete_channel"},{label:m("æµè¯æ¸ é"),value:"test_channel"}],ee=()=>{const e=Z?Z.getValues():{};return{targetId:e.targetId||"",operatorName:e.operatorName||"",operationCategory:e.operationCategory||"",operationType:e.operationType||"",targetName:e.targetName||"",description:e.description||""}},ae=e=>{switch(e){case"user_management":return a.jsx(D,{size:14,className:"text-blue-500"});case"channel_management":return a.jsx(E,{size:14,className:"text-green-500"});case"token_management":return a.jsx(P,{size:14,className:"text-purple-500"});case"system_config":return a.jsx(k,{size:14,className:"text-orange-500"});case"redemption_management":return a.jsx(T,{size:14,className:"text-pink-500"});case"log_management":return a.jsx(S,{size:14,className:"text-gray-500"});default:return a.jsx(z,{size:14,className:"text-red-500"})}},te=e=>e.field_name?a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{children:[a.jsxs(L,{strong:!0,className:"text-xs",children:[m("åæ®µ"),":"]}),a.jsx(L,{className:"ml-2 text-xs",children:e.field_name})]}),e.old_value&&a.jsxs("div",{children:[a.jsxs(L,{strong:!0,className:"text-xs",children:[m("åå¼"),":"]}),a.jsx(L,{className:"ml-2 text-xs text-red-500",children:e.old_value})]}),e.new_value&&a.jsxs("div",{children:[a.jsxs(L,{strong:!0,className:"text-xs",children:[m("æ°å¼"),":"]}),a.jsx(L,{className:"ml-2 text-xs text-green-500",children:e.new_value})]})]}):a.jsx(L,{type:"secondary",children:m("æ åæ®µåæ´")}),se=[{title:"ID",dataIndex:"id",width:60},{title:m("æä½æ¶é´"),dataIndex:"created_at",width:150,render:e=>a.jsx(d,{content:l(e),position:"top",children:a.jsx(L,{className:"text-xs",children:l(e)})})},{title:m("æä½å"),dataIndex:"operator_name",width:120,render:(e,t)=>{return a.jsxs(p,{vertical:!0,spacing:1,children:[a.jsx(L,{strong:!0,className:"text-sm",children:e}),(s=t.operator_role,r(s,m,"small"))]});var s}},{title:m("æä½åç±»"),dataIndex:"operation_category",width:100,render:e=>(e=>{const t={user_management:{label:m("ç¨æ·ç®¡ç"),color:"blue"},channel_management:{label:m("æ¸ é管ç"),color:"green"},token_management:{label:m("令ç管ç"),color:"purple"},system_config:{label:m("ç³»ç»é
ç½®"),color:"orange"},redemption_management:{label:m("å
æ¢ç 管ç"),color:"pink"},log_management:{label:m("æ¥å¿ç®¡ç"),color:"grey"}}[e]||{label:e,color:"red"};return a.jsx(u,{size:"small",color:t.color,prefixIcon:ae(e),children:t.label})})(e)},{title:m("æä½ç±»å"),dataIndex:"operation_type",width:100,render:e=>{return a.jsx(u,{size:"small",color:"cyan",children:(t=e,{update_quota:m("ä¿®æ¹é¢åº¦"),update_password:m("ä¿®æ¹å¯ç "),update_role:m("ä¿®æ¹è§è²"),update_status:m("ä¿®æ¹ç¶æ"),update_profile:m("ä¿®æ¹ç¨æ·ä¿¡æ¯"),create_user:m("åå»ºç¨æ·"),delete_user:m("å é¤ç¨æ·"),manage_user:m("管çç¨æ·"),preview_user_migration:m("é¢è§å¤äººè¿ç§»"),execute_user_migration:m("æ§è¡å¤äººè¿ç§»"),preview_user_migration_single:m("é¢è§å人è¿ç§»"),execute_user_migration_single:m("æ§è¡å人è¿ç§»"),send_migration_emails:m("åéè¿ç§»éç¥é®ä»¶"),preview_user_migration_rollback:m("é¢è§ç¨æ·è¿ç§»åæ»"),execute_user_migration_rollback:m("æ§è¡ç¨æ·è¿ç§»åæ»"),create_channel:m("åå»ºæ¸ é"),update_channel:m("æ´æ°æ¸ é"),delete_channel:m("å 餿¸ é"),test_channel:m("æµè¯æ¸ é")}[t]||t)});var t}},{title:m("ç®æ 对象"),dataIndex:"target_name",width:120,render:(e,t)=>e?a.jsxs(p,{vertical:!0,spacing:1,children:[a.jsx(L,{className:"text-sm",children:e}),t.target_id>0&&a.jsxs(L,{type:"secondary",className:"text-xs",children:["ID: ",t.target_id]})]}):a.jsx(L,{type:"secondary",children:"-"})},{title:m("æä½æè¿°"),dataIndex:"description",render:e=>a.jsx(d,{content:e,position:"top",children:a.jsx(L,{className:"text-sm max-w-xs truncate",children:e})})},{title:m("åæ´è¯¦æ
"),dataIndex:"details",width:200,render:(e,t)=>a.jsx(d,{content:te(t),position:"top",children:a.jsx("div",{className:"cursor-pointer",children:te(t)})})},{title:m("IPå°å"),dataIndex:"ip_address",width:120,render:e=>a.jsx(L,{className:"text-xs font-mono",children:e||"-"})}],le=async(e,a)=>{try{K(!0);const t=await n.get(`/api/operation_log/?p=${e}&page_size=${a}`),{success:s,message:l,data:r}=t.data;s?(V(r.items||[]),A(r.page||e),F(r.total||0)):i(l)}catch(t){i(m("å è½½æä½æ¥å¿å¤±è´¥")+"ï¼"+t.message)}finally{K(!1)}},re=async(e,a,t=null)=>{null===t&&(t=ee());const{targetId:s,operatorName:l,operationCategory:r,operationType:o,targetName:c,description:d}=t;if(s||l||r||o||c||d)try{W(!0);const t=new URLSearchParams;s&&t.append("target_id",s),l&&t.append("operator_name",l),r&&t.append("operation_category",r),o&&t.append("operation_type",o),c&&t.append("target_name",c),d&&t.append("description",d),t.append("p",e),t.append("page_size",a);const m=await n.get(`/api/operation_log/search?${t.toString()}`),{success:p,message:u,data:x}=m.data;p?(V(x.items||[]),A(x.page||e),F(x.total||0)):i(u)}catch(m){i("æç´¢æä½æ¥å¿å¤±è´¥ï¼"+m.message)}finally{W(!1)}else await le(e,a)},ne=async()=>{A(1);const e=ee();e.targetId||e.operatorName||e.operationCategory||e.operationType||e.targetName||e.description?await re(1,O,e):await le(1,O)};return e.useEffect(()=>{le(1,O)},[]),a.jsx("div",{className:"",children:a.jsx(x,{className:"!rounded-2xl",title:a.jsxs("div",{className:"flex flex-col w-full",children:[a.jsx("div",{className:"mb-2",children:a.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:[a.jsxs("div",{className:"flex items-center text-blue-500",children:[a.jsx(b,{size:16,className:"mr-2"}),a.jsx(L,{children:m("æ¥çç³»ç»ä¸ææçæä½è®°å½ï¼å
æ¬ç¨æ·ç®¡çãç³»ç»é
ç½®çæä½çè¯¦ç»æ¥å¿ã")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(j,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>Y(!X),size:"small",children:m(X?"èªéåºå表":"ç´§åå表")}),o()&&a.jsx(j,{theme:"light",type:"secondary",icon:a.jsx(I,{size:16}),onClick:()=>{v.confirm({title:m("确认å é¤"),content:m("ç¡®å®è¦å é¤30天åçæä½è®°å½åï¼æ¤æä½ä¸å¯éã"),onOk:async()=>{try{const e=await n.delete("/api/operation_log/?days=30"),{success:a,message:t}=e.data;a?(c(m("å 餿å")),await ne()):i(t)}catch(e){i("å é¤å¤±è´¥ï¼"+e.message)}}})},className:"w-full md:w-auto",children:m("æ¸
çå岿¥å¿")})]})]})}),a.jsx(f,{margin:"12px"}),a.jsx(w,{initValues:{targetId:"",operatorName:"",operationCategory:"",operationType:"",targetName:"",description:""},getFormApi:e=>G(e),onSubmit:()=>{A(1),re(1,O)},allowEmpty:!0,autoComplete:"off",layout:"horizontal",trigger:"change",stopValidateWithError:!1,className:"w-full",children:a.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[a.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3 w-full",children:[a.jsx("div",{className:"w-full md:w-40",children:a.jsx(w.Input,{field:"targetId",placeholder:m("ç®æ ID"),showClear:!0,pure:!0})}),a.jsx("div",{className:"w-full md:w-48",children:a.jsx(w.Input,{field:"operatorName",placeholder:m("æä½ååç§°"),showClear:!0,pure:!0})}),a.jsx("div",{className:"w-full md:w-48",children:a.jsx(w.Select,{field:"operationCategory",placeholder:m("æä½åç±»"),optionList:H,className:"w-full",showClear:!0,pure:!0})}),a.jsx("div",{className:"w-full md:w-48",children:a.jsx(w.Select,{field:"operationType",placeholder:m("æä½ç±»å"),optionList:Q,className:"w-full",showClear:!0,pure:!0})})]}),a.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3 w-full",children:[a.jsx("div",{className:"relative flex-1 w-full",children:a.jsx(w.Input,{field:"targetName",prefix:a.jsx(C,{size:16}),placeholder:m("ç®æ 对象åç§°"),showClear:!0,pure:!0})}),a.jsx("div",{className:"relative flex-1 w-full",children:a.jsx(w.Input,{field:"description",prefix:a.jsx(C,{size:16}),placeholder:m("æä½æè¿°"),showClear:!0,pure:!0})}),a.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[a.jsx(j,{type:"primary",htmlType:"submit",loading:$||U,className:"flex-1 md:flex-initial md:w-auto",children:m("æ¥è¯¢")}),a.jsx(j,{theme:"light",onClick:()=>{Z&&(Z.reset(),setTimeout(()=>{A(1),le(1,O)},100))},className:"flex-1 md:flex-initial md:w-auto",children:m("éç½®")})]})]})]})})]}),shadows:"always",bordered:!1,children:a.jsx(y,{columns:se,dataSource:M,scroll:X?void 0:{x:"max-content"},pagination:{formatPageText:e=>m("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:B}),currentPage:q,pageSize:O,total:B,pageSizeOpts:[10,20,50,100],showSizeChanger:!0,onPageSizeChange:async e=>{R(e),A(1),J.current=!0;const a=ee(),t=a.targetId||a.operatorName||a.operationCategory||a.operationType||a.targetName||a.description;try{t?await re(1,e,a):await le(1,e)}finally{J.current=!1}},onPageChange:e=>{if(J.current)return;A(e);const a=ee();a.targetId||a.operatorName||a.operationCategory||a.operationType||a.targetName||a.description?re(e,O,a):le(e,O)}},loading:$,empty:a.jsx(g,{image:a.jsx(_,{style:{width:150,height:150}}),darkModeImage:a.jsx(h,{style:{width:150,height:150}}),description:m("ææ æä½è®°å½"),style:{padding:30}}),className:"overflow-hidden",size:"small",rowKey:"id"})})})};export{V as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.