F1 告警静默规则 [done]: - 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式) - 告警引擎 isSilenced 集成 (alert_engine.go) - 前端 SilenceRuleTab + SilenceDialog - 路由 /alerts/silences 已注册 F2 审计日志导出 [done]: - 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM) - 支持 module/action/username/startTime/endTime 筛选 - 导出限制 10000 条防溢出,自动记录审计日志 - JSON 格式向后兼容 (format=json) - 前端 exportLogs 传递查询参数 同时包含累积的前期工作: - 目录重构 internal/ -> controller/model/router (v0.55-v0.57) - 后端分层架构 dto/repository/service/utils - 审计模块全功能 (终端审计/操作审计/登录日志) - asciicast v2 录制格式 - SFTP 文件浏览器 - StatStrip 紧凑统计条 - 在线会话自动刷新 - LiveMonitor WebSocket 诊断修复 验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
3 lines
95 KiB
JavaScript
3 lines
95 KiB
JavaScript
import{r as o,u as q,j as s,D as X,b as G,c as Y,d as Z,a8 as le,e as ss,I as S,f as ms,B as i,P as qs,a3 as Js,N as Ws,L as Ns,S as Ne,U as re,t as Us,a as Xs,a4 as ve,aa as de,y as Vs,V as Te,E as pe,l as z,z as Le}from"./index-DfyorCky.js";import{T as De,a as fe,b as Hs,c as Ks}from"./tabs-CIh_yD4s.js";import{B as os}from"./badge-xNW8x0G1.js";import{C as xs,a as hs,b as Ss,c as js,d as us}from"./card-C55cvSHg.js";import{T as Ps,a as zs,b as J,c as U,d as Es,e as T}from"./table-5sHV4Akp.js";import{S as ws,a as Cs,b as Ms,c as Is,d as B}from"./select-D5qUzdAs.js";import{S as vs}from"./square-pen-BxUFAe0F.js";import{U as Qs}from"./upload-Ba6rlaGS.js";import{D as ie}from"./download-DoZfYs2h.js";import{C as Gs}from"./circle-x-DK79Dhg2.js";import{R as Ys}from"./refresh-cw-DUB_tAG-.js";import{P as Zs}from"./plus-CUG-9kpu.js";import{M as Ue,P as we}from"./phone-DgvWDdJl.js";import{T as se}from"./trash-2-Dx32pOzT.js";import{t as Q}from"./index-a3ybMjbR.js";import{T as Ce}from"./textarea-NXY8u32k.js";import{L as fs}from"./label-BK0h2apY.js";import{C as Me}from"./checkbox-CH0bpj6b.js";import{S as bs}from"./switch-CGiGgOnh.js";import{U as Ie}from"./user-plus-BwUWtcQl.js";import{H as ke}from"./history-D_9jPUQg.js";import"./index-CWVNW_qu.js";function Re({open:e,onOpenChange:r,editingUser:t,form:n,setForm:d,saving:x,onSubmit:D}){const[N,b]=o.useState([]);return o.useEffect(()=>{if(!e)return;let a=!1;return(async()=>{try{const u=await q.getRoles();if(a)return;const I=u?.list??[];b(I.map(L=>({id:String(L.id??""),name:L.name??L.code??""})))}catch{a||b([])}})(),()=>{a=!0}},[e]),s.jsx(X,{"code-path":"src/components/system/UserFormDialog.tsx:78:5",open:e,onOpenChange:r,children:s.jsxs(G,{"code-path":"src/components/system/UserFormDialog.tsx:79:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/UserFormDialog.tsx:80:9",children:[s.jsxs(Z,{"code-path":"src/components/system/UserFormDialog.tsx:81:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(le,{"code-path":"src/components/system/UserFormDialog.tsx:82:13",className:"h-5 w-5 text-blue-400"}),t?"编辑用户":"新建用户"]}),s.jsx(ss,{"code-path":"src/components/system/UserFormDialog.tsx:85:11",className:"text-slate-500",children:t?"修改用户信息":"创建新的系统用户"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:90:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:91:11",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:92:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:93:15",className:"text-xs text-slate-500",children:"用户名"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:94:15",value:n.username,onChange:a=>d({...n,username:a.target.value}),disabled:!!t,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"登录用户名"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:102:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:103:15",className:"text-xs text-slate-500",children:"昵称"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:104:15",value:n.nickname,onChange:a=>d({...n,nickname:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"显示昵称"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:111:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:112:15",className:"text-xs text-slate-500",children:"邮箱"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:113:15",value:n.email,onChange:a=>d({...n,email:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"user@example.com"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:120:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:121:15",className:"text-xs text-slate-500",children:"手机号"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:122:15",value:n.phone,onChange:a=>d({...n,phone:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"可选"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:129:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:130:15",className:"text-xs text-slate-500",children:"角色"}),s.jsxs(ws,{"code-path":"src/components/system/UserFormDialog.tsx:131:15",value:n.role,onValueChange:a=>d({...n,role:a}),children:[s.jsx(Cs,{"code-path":"src/components/system/UserFormDialog.tsx:132:17",className:"bg-slate-800/50 border-slate-700 text-slate-200",children:s.jsx(Ms,{"code-path":"src/components/system/UserFormDialog.tsx:133:19",placeholder:"选择角色"})}),s.jsx(Is,{"code-path":"src/components/system/UserFormDialog.tsx:135:17",className:"bg-slate-800 border-slate-700",children:N.map(a=>s.jsx(B,{"code-path":"src/components/system/UserFormDialog.tsx:137:21",value:a.name,children:a.name},a.id))})]})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:144:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:145:15",className:"text-xs text-slate-500",children:"状态"}),s.jsxs(ws,{"code-path":"src/components/system/UserFormDialog.tsx:146:15",value:String(n.status),onValueChange:a=>d({...n,status:Number(a)}),children:[s.jsx(Cs,{"code-path":"src/components/system/UserFormDialog.tsx:150:17",className:"bg-slate-800/50 border-slate-700 text-slate-200",children:s.jsx(Ms,{"code-path":"src/components/system/UserFormDialog.tsx:151:19"})}),s.jsxs(Is,{"code-path":"src/components/system/UserFormDialog.tsx:153:17",className:"bg-slate-800 border-slate-700",children:[s.jsx(B,{"code-path":"src/components/system/UserFormDialog.tsx:154:19",value:"1",children:"正常"}),s.jsx(B,{"code-path":"src/components/system/UserFormDialog.tsx:155:19",value:"0",children:"禁用"})]})]})]})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:160:11",className:"space-y-2",children:[s.jsxs("label",{"code-path":"src/components/system/UserFormDialog.tsx:161:13",className:"text-xs text-slate-500",children:["密码",t?"(留空则不修改)":""]}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:164:13",type:"password",value:n.password,onChange:a=>d({...n,password:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:t?"留空则不修改":"设置初始密码"})]})]}),s.jsxs(ms,{"code-path":"src/components/system/UserFormDialog.tsx:174:9",children:[s.jsx(i,{"code-path":"src/components/system/UserFormDialog.tsx:175:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>r(!1),children:"取消"}),s.jsx(i,{"code-path":"src/components/system/UserFormDialog.tsx:178:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:D,disabled:x,children:x?"保存中...":"保存"})]})]})})}function Fe({selectedUser:e,setSelectedUser:r,getUserStatusBadge:t,openEdit:n}){return s.jsx(X,{"code-path":"src/components/system/UserDetailDialog.tsx:29:5",open:!!e,onOpenChange:()=>r(null),children:s.jsxs(G,{"code-path":"src/components/system/UserDetailDialog.tsx:30:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/UserDetailDialog.tsx:31:9",children:[s.jsxs(Z,{"code-path":"src/components/system/UserDetailDialog.tsx:32:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(le,{"code-path":"src/components/system/UserDetailDialog.tsx:33:13",className:"h-5 w-5 text-blue-400"}),e?.nickname]}),s.jsxs(ss,{"code-path":"src/components/system/UserDetailDialog.tsx:36:11",className:"text-slate-500",children:["@",e?.username," · ",e?.email]})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:41:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:42:11",className:"grid grid-cols-2 gap-4 p-4 rounded-lg bg-slate-800/50",children:[s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:43:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:44:15",className:"text-xs text-slate-500 mb-1",children:"用户名"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:45:15",className:"text-sm text-slate-200",children:e?.username})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:47:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:48:15",className:"text-xs text-slate-500 mb-1",children:"昵称"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:49:15",className:"text-sm text-slate-200",children:e?.nickname})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:51:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:52:15",className:"text-xs text-slate-500 mb-1",children:"邮箱"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:53:15",className:"text-sm text-slate-200",children:e?.email})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:55:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:56:15",className:"text-xs text-slate-500 mb-1",children:"手机号"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:57:15",className:"text-sm text-slate-200",children:e?.phone||"--"})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:59:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:60:15",className:"text-xs text-slate-500 mb-1",children:"状态"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:61:15",className:"text-sm text-slate-200",children:e&&t(e.status)})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:63:13",children:[s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:64:15",className:"text-xs text-slate-500 mb-1",children:"创建时间"}),s.jsx("p",{"code-path":"src/components/system/UserDetailDialog.tsx:65:15",className:"text-sm text-slate-200",children:e&&e.createdAt?new Date(e.createdAt).toLocaleDateString():"--"})]})]}),s.jsxs("div",{"code-path":"src/components/system/UserDetailDialog.tsx:71:11",children:[s.jsx("h4",{"code-path":"src/components/system/UserDetailDialog.tsx:72:13",className:"text-sm font-medium text-slate-300 mb-2",children:"角色"}),s.jsx("div",{"code-path":"src/components/system/UserDetailDialog.tsx:73:13",className:"flex flex-wrap gap-2",children:e?.roles.map(d=>s.jsx(os,{"code-path":"src/components/system/UserDetailDialog.tsx:75:17",variant:"outline",className:"border-slate-700 text-slate-400",children:d},d))})]})]}),s.jsxs(ms,{"code-path":"src/components/system/UserDetailDialog.tsx:83:9",children:[s.jsxs(i,{"code-path":"src/components/system/UserDetailDialog.tsx:84:11",variant:"outline",className:"border-slate-700 text-slate-300",children:[s.jsx(qs,{"code-path":"src/components/system/UserDetailDialog.tsx:85:13",className:"h-4 w-4 mr-2"}),"重置密码"]}),s.jsxs(i,{"code-path":"src/components/system/UserDetailDialog.tsx:88:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>{e&&(r(null),n(e))},children:[s.jsx(vs,{"code-path":"src/components/system/UserDetailDialog.tsx:97:13",className:"h-4 w-4 mr-2"}),"编辑"]})]})]})})}function _e({importDialogOpen:e,setImportDialogOpen:r,importPreview:t,setImportPreview:n,importing:d,importResult:x,setImportResult:D,handleCsvUpload:N,handleBatchImport:b}){return s.jsx(X,{"code-path":"src/components/system/CsvImportDialog.tsx:47:5",open:e==="csv",onOpenChange:a=>!a&&r(null),children:s.jsxs(G,{"code-path":"src/components/system/CsvImportDialog.tsx:48:7",className:"bg-slate-900 border-slate-800 max-w-2xl",children:[s.jsxs(Y,{"code-path":"src/components/system/CsvImportDialog.tsx:49:9",children:[s.jsxs(Z,{"code-path":"src/components/system/CsvImportDialog.tsx:50:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Qs,{"code-path":"src/components/system/CsvImportDialog.tsx:51:13",className:"h-5 w-5 text-blue-400"}),"批量导入用户(CSV)"]}),s.jsx(ss,{"code-path":"src/components/system/CsvImportDialog.tsx:54:11",className:"text-slate-500",children:"上传 CSV 文件批量创建用户。请先下载模板,按格式填写后上传。"})]}),x?s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:120:11",className:"space-y-4 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:121:13",className:`flex items-center gap-3 p-4 rounded-lg ${x.code===200?"bg-emerald-500/10":"bg-red-500/10"}`,children:[x.code===200?s.jsx(Js,{"code-path":"src/components/system/CsvImportDialog.tsx:123:17",className:"h-6 w-6 text-emerald-400 shrink-0"}):s.jsx(Gs,{"code-path":"src/components/system/CsvImportDialog.tsx:125:17",className:"h-6 w-6 text-red-400 shrink-0"}),s.jsx("span",{"code-path":"src/components/system/CsvImportDialog.tsx:127:15",className:"text-sm text-slate-200",children:x.message})]}),x.errors?.length>0&&s.jsx("div",{"code-path":"src/components/system/CsvImportDialog.tsx:130:15",className:"max-h-32 overflow-auto rounded-lg bg-slate-800/50 p-3 space-y-1",children:x.errors.map((a,u)=>s.jsx("div",{"code-path":"src/components/system/CsvImportDialog.tsx:132:19",className:"text-xs text-red-400",children:a},u))}),s.jsx(ms,{"code-path":"src/components/system/CsvImportDialog.tsx:136:13",children:s.jsx(i,{"code-path":"src/components/system/CsvImportDialog.tsx:137:15",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>{r(null),n([]),D(null)},children:"完成"})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:61:13",className:"space-y-3",children:[s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:62:15",className:"flex items-center gap-2",children:[s.jsxs(i,{"code-path":"src/components/system/CsvImportDialog.tsx:63:17",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:()=>q.downloadTemplate(),children:[s.jsx(ie,{"code-path":"src/components/system/CsvImportDialog.tsx:64:19",className:"h-4 w-4 mr-1.5"}),"下载模板"]}),s.jsxs("label",{"code-path":"src/components/system/CsvImportDialog.tsx:67:17",className:"inline-flex items-center px-3 py-1.5 rounded-md text-sm bg-slate-800 border border-slate-700 text-slate-200 cursor-pointer hover:bg-slate-700 transition-colors",children:[s.jsx(Qs,{"code-path":"src/components/system/CsvImportDialog.tsx:68:19",className:"h-4 w-4 mr-1.5"}),"选择 CSV 文件",s.jsx("input",{"code-path":"src/components/system/CsvImportDialog.tsx:70:19",type:"file",accept:".csv",className:"hidden",onChange:N})]})]}),t.length>0&&s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:75:17",className:"rounded-lg border border-slate-800 overflow-hidden",children:[s.jsxs("div",{"code-path":"src/components/system/CsvImportDialog.tsx:76:19",className:"px-3 py-2 bg-slate-800/50 text-xs text-slate-400",children:["预览:",t.length," 条数据"]}),s.jsxs(Ps,{"code-path":"src/components/system/CsvImportDialog.tsx:79:19",children:[s.jsx(zs,{"code-path":"src/components/system/CsvImportDialog.tsx:80:21",children:s.jsxs(J,{"code-path":"src/components/system/CsvImportDialog.tsx:81:23",className:"border-slate-800",children:[s.jsx(U,{"code-path":"src/components/system/CsvImportDialog.tsx:82:25",className:"text-slate-400 text-xs",children:"用户名"}),s.jsx(U,{"code-path":"src/components/system/CsvImportDialog.tsx:83:25",className:"text-slate-400 text-xs",children:"昵称"}),s.jsx(U,{"code-path":"src/components/system/CsvImportDialog.tsx:84:25",className:"text-slate-400 text-xs",children:"邮箱"}),s.jsx(U,{"code-path":"src/components/system/CsvImportDialog.tsx:85:25",className:"text-slate-400 text-xs",children:"手机"})]})}),s.jsxs(Es,{"code-path":"src/components/system/CsvImportDialog.tsx:88:21",children:[t.slice(0,5).map((a,u)=>s.jsxs(J,{"code-path":"src/components/system/CsvImportDialog.tsx:90:25",className:"border-slate-800",children:[s.jsx(T,{"code-path":"src/components/system/CsvImportDialog.tsx:91:27",className:"text-slate-200 text-xs",children:a.username}),s.jsx(T,{"code-path":"src/components/system/CsvImportDialog.tsx:92:27",className:"text-slate-300 text-xs",children:a.nickname}),s.jsx(T,{"code-path":"src/components/system/CsvImportDialog.tsx:93:27",className:"text-slate-400 text-xs",children:a.email}),s.jsx(T,{"code-path":"src/components/system/CsvImportDialog.tsx:94:27",className:"text-slate-400 text-xs",children:a.phone})]},u)),t.length>5&&s.jsx(J,{"code-path":"src/components/system/CsvImportDialog.tsx:98:25",className:"border-slate-800",children:s.jsxs(T,{"code-path":"src/components/system/CsvImportDialog.tsx:99:27",colSpan:4,className:"text-slate-500 text-xs text-center",children:["还有 ",t.length-5," 条..."]})})]})]})]})]}),s.jsxs(ms,{"code-path":"src/components/system/CsvImportDialog.tsx:110:13",children:[s.jsx(i,{"code-path":"src/components/system/CsvImportDialog.tsx:111:15",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>{r(null),n([])},children:"取消"}),s.jsx(i,{"code-path":"src/components/system/CsvImportDialog.tsx:114:15",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:b,disabled:d||t.length===0,children:d?"导入中...":`确认导入 (${t.length})`})]})]})]})})}function Oe({importDialogOpen:e,setImportDialogOpen:r,ldapUsers:t,setLdapUsers:n,ldapSelected:d,setLdapSelected:x,ldapLoading:D,ldapImportOUs:N,ldapImportOUDN:b,setLdapImportOUDN:a,loadLdapUsers:u,handleLdapImport:I,importing:L,importResult:w,setImportResult:R}){return s.jsx(X,{"code-path":"src/components/system/LdapImportDialog.tsx:58:5",open:e==="ldap",onOpenChange:y=>!y&&r(null),children:s.jsxs(G,{"code-path":"src/components/system/LdapImportDialog.tsx:59:7",className:"bg-slate-900 border-slate-800 max-w-2xl",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapImportDialog.tsx:60:9",children:[s.jsxs(Z,{"code-path":"src/components/system/LdapImportDialog.tsx:61:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Ws,{"code-path":"src/components/system/LdapImportDialog.tsx:62:13",className:"h-5 w-5 text-cyan-400"}),"从 LDAP 导入用户"]}),s.jsx(ss,{"code-path":"src/components/system/LdapImportDialog.tsx:65:11",className:"text-slate-500",children:"从 LDAP 服务器检索用户列表,选择需要导入的用户"})]}),w?s.jsxs("div",{"code-path":"src/components/system/LdapImportDialog.tsx:163:11",className:"space-y-4 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/LdapImportDialog.tsx:164:13",className:`flex items-center gap-3 p-4 rounded-lg ${w.code===200?"bg-emerald-500/10":"bg-red-500/10"}`,children:[w.code===200?s.jsx(Js,{"code-path":"src/components/system/LdapImportDialog.tsx:166:17",className:"h-6 w-6 text-emerald-400 shrink-0"}):s.jsx(Gs,{"code-path":"src/components/system/LdapImportDialog.tsx:168:17",className:"h-6 w-6 text-red-400 shrink-0"}),s.jsx("span",{"code-path":"src/components/system/LdapImportDialog.tsx:170:15",className:"text-sm text-slate-200",children:w.message})]}),s.jsx(ms,{"code-path":"src/components/system/LdapImportDialog.tsx:172:13",children:s.jsx(i,{"code-path":"src/components/system/LdapImportDialog.tsx:173:15",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>{r(null),n([]),R(null)},children:"完成"})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{"code-path":"src/components/system/LdapImportDialog.tsx:72:13",className:"space-y-3",children:[s.jsxs("div",{"code-path":"src/components/system/LdapImportDialog.tsx:73:15",className:"flex items-center gap-3",children:[s.jsxs("div",{"code-path":"src/components/system/LdapImportDialog.tsx:74:17",className:"flex items-center gap-2",children:[s.jsx("span",{"code-path":"src/components/system/LdapImportDialog.tsx:75:19",className:"text-xs text-slate-500 whitespace-nowrap",children:"选择 OU"}),s.jsxs("select",{"code-path":"src/components/system/LdapImportDialog.tsx:76:19",className:"bg-slate-800 border border-slate-700 text-slate-200 text-xs rounded-md px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-blue-500",value:b,onChange:y=>{a(y.target.value),u(y.target.value)},children:[s.jsx("option",{"code-path":"src/components/system/LdapImportDialog.tsx:84:21",value:"",children:"根 (全部)"}),N.map(y=>s.jsx("option",{"code-path":"src/components/system/LdapImportDialog.tsx:86:23",value:y.dn,children:y.name},y.dn))]})]}),s.jsxs(i,{"code-path":"src/components/system/LdapImportDialog.tsx:90:17",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300 ml-auto",onClick:()=>u(b),disabled:D,children:[D?s.jsx(Ns,{"code-path":"src/components/system/LdapImportDialog.tsx:91:34",className:"h-4 w-4 mr-1.5 animate-spin"}):s.jsx(Ys,{"code-path":"src/components/system/LdapImportDialog.tsx:91:88",className:"h-4 w-4 mr-1.5"}),"刷新"]})]}),s.jsx("p",{"code-path":"src/components/system/LdapImportDialog.tsx:96:15",className:"text-xs text-slate-500",children:t.length>0?`找到 ${t.length} 个用户`:"选择 OU 或点击刷新获取用户列表"}),t.length>0&&s.jsx("div",{"code-path":"src/components/system/LdapImportDialog.tsx:101:17",className:"max-h-80 overflow-auto rounded-lg border border-slate-800",children:s.jsxs(Ps,{"code-path":"src/components/system/LdapImportDialog.tsx:102:19",children:[s.jsx(zs,{"code-path":"src/components/system/LdapImportDialog.tsx:103:21",children:s.jsxs(J,{"code-path":"src/components/system/LdapImportDialog.tsx:104:23",className:"border-slate-800 sticky top-0 bg-slate-900",children:[s.jsx(U,{"code-path":"src/components/system/LdapImportDialog.tsx:105:25",className:"w-10 text-slate-400 text-xs",children:s.jsx("input",{"code-path":"src/components/system/LdapImportDialog.tsx:106:27",type:"checkbox",className:"accent-blue-600",checked:d.size===t.length&&t.length>0,onChange:y=>{y.target.checked?x(new Set(t.map(k=>k.dn))):x(new Set)}})}),s.jsx(U,{"code-path":"src/components/system/LdapImportDialog.tsx:119:25",className:"text-slate-400 text-xs",children:"用户名"}),s.jsx(U,{"code-path":"src/components/system/LdapImportDialog.tsx:120:25",className:"text-slate-400 text-xs",children:"显示名"}),s.jsx(U,{"code-path":"src/components/system/LdapImportDialog.tsx:121:25",className:"text-slate-400 text-xs",children:"邮箱"}),s.jsx(U,{"code-path":"src/components/system/LdapImportDialog.tsx:122:25",className:"text-slate-400 text-xs",children:"DN"})]})}),s.jsx(Es,{"code-path":"src/components/system/LdapImportDialog.tsx:125:21",children:t.map(y=>s.jsxs(J,{"code-path":"src/components/system/LdapImportDialog.tsx:127:25",className:"border-slate-800 hover:bg-slate-800/50",children:[s.jsx(T,{"code-path":"src/components/system/LdapImportDialog.tsx:128:27",children:s.jsx("input",{"code-path":"src/components/system/LdapImportDialog.tsx:129:29",type:"checkbox",className:"accent-blue-600",checked:d.has(y.dn),onChange:k=>{const f=new Set(d);k.target.checked?f.add(y.dn):f.delete(y.dn),x(f)}})}),s.jsx(T,{"code-path":"src/components/system/LdapImportDialog.tsx:141:27",className:"text-slate-200 text-xs",children:y.uid}),s.jsx(T,{"code-path":"src/components/system/LdapImportDialog.tsx:142:27",className:"text-slate-300 text-xs",children:y.cn}),s.jsx(T,{"code-path":"src/components/system/LdapImportDialog.tsx:143:27",className:"text-slate-400 text-xs",children:y.mail}),s.jsx(T,{"code-path":"src/components/system/LdapImportDialog.tsx:144:27",className:"text-slate-500 text-xs font-mono truncate max-w-[200px]",children:y.dn})]},y.dn))})]})})]}),s.jsxs(ms,{"code-path":"src/components/system/LdapImportDialog.tsx:153:13",children:[s.jsx(i,{"code-path":"src/components/system/LdapImportDialog.tsx:154:15",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>{r(null),n([])},children:"取消"}),s.jsx(i,{"code-path":"src/components/system/LdapImportDialog.tsx:157:15",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:I,disabled:L||d.size===0,children:L?"导入中...":`导入选中 (${d.size})`})]})]})]})})}function Ae({searchQuery:e,setSearchQuery:r,filteredUsers:t,loading:n,selectedUser:d,setSelectedUser:x,getUserStatusBadge:D,dialogOpen:N,setDialogOpen:b,editingUser:a,form:u,setForm:I,saving:L,handleSubmit:w,openCreate:R,openEdit:y,handleDelete:k,importDialogOpen:f,setImportDialogOpen:A,importPreview:F,setImportPreview:E,importing:C,importResult:_,setImportResult:p,handleCsvUpload:O,handleBatchImport:g,ldapUsers:$,ldapSelected:es,setLdapSelected:ts,ldapLoading:W,ldapImportOUs:j,ldapImportOUDN:ls,setLdapImportOUDN:as,loadLdapUsers:rs,handleLdapImport:ds,setLdapUsers:V}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:114:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:115:9",className:"relative w-64",children:[s.jsx(Ne,{"code-path":"src/components/system/SystemUserTab.tsx:116:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),s.jsx(S,{"code-path":"src/components/system/SystemUserTab.tsx:117:11",placeholder:"搜索用户...",value:e,onChange:v=>r(v.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:124:9",className:"flex items-center gap-2",children:[s.jsxs(i,{"code-path":"src/components/system/SystemUserTab.tsx:125:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:()=>A("csv"),children:[s.jsx(Qs,{"code-path":"src/components/system/SystemUserTab.tsx:126:13",className:"h-4 w-4 mr-2"}),"批量导入"]}),s.jsxs(i,{"code-path":"src/components/system/SystemUserTab.tsx:129:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:()=>A("ldap"),children:[s.jsx(Ws,{"code-path":"src/components/system/SystemUserTab.tsx:130:13",className:"h-4 w-4 mr-2"}),"LDAP 导入"]}),s.jsxs(i,{"code-path":"src/components/system/SystemUserTab.tsx:133:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:R,children:[s.jsx(Zs,{"code-path":"src/components/system/SystemUserTab.tsx:134:13",className:"h-4 w-4 mr-2"}),"新建用户"]})]})]}),s.jsx(xs,{"code-path":"src/components/system/SystemUserTab.tsx:141:7",className:"bg-slate-900 border-slate-800",children:s.jsx(hs,{"code-path":"src/components/system/SystemUserTab.tsx:142:9",className:"p-0",children:s.jsx("div",{"code-path":"src/components/system/SystemUserTab.tsx:143:11",className:"border-t border-slate-800",children:s.jsxs(Ps,{"code-path":"src/components/system/SystemUserTab.tsx:144:13",children:[s.jsx(zs,{"code-path":"src/components/system/SystemUserTab.tsx:145:15",children:s.jsxs(J,{"code-path":"src/components/system/SystemUserTab.tsx:146:17",className:"border-slate-800 hover:bg-transparent",children:[s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:147:19",className:"text-slate-400",children:"用户信息"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:148:19",className:"text-slate-400",children:"联系方式"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:149:19",className:"text-slate-400",children:"角色"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:150:19",className:"text-slate-400",children:"来源"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:151:19",className:"text-slate-400",children:"状态"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:152:19",className:"text-slate-400",children:"最后登录"}),s.jsx(U,{"code-path":"src/components/system/SystemUserTab.tsx:153:19",className:"text-slate-400 text-right",children:"操作"})]})}),s.jsx(Es,{"code-path":"src/components/system/SystemUserTab.tsx:156:15",children:n?s.jsx(J,{"code-path":"src/components/system/SystemUserTab.tsx:158:19",className:"border-slate-800",children:s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:159:21",colSpan:7,className:"text-center py-12",children:s.jsx("div",{"code-path":"src/components/system/SystemUserTab.tsx:160:23",className:"flex items-center justify-center",children:s.jsx("div",{"code-path":"src/components/system/SystemUserTab.tsx:161:25",className:"h-6 w-6 border-2 border-slate-700 border-t-blue-500 rounded-full animate-spin"})})})}):t.length===0?s.jsx(J,{"code-path":"src/components/system/SystemUserTab.tsx:166:19",className:"border-slate-800",children:s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:167:21",colSpan:7,className:"text-center py-12 text-sm text-slate-500",children:"暂无用户数据"})}):t.map(v=>s.jsxs(J,{"code-path":"src/components/system/SystemUserTab.tsx:173:21",className:"border-slate-800 hover:bg-slate-800/50",children:[s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:174:23",children:s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:175:25",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/system/SystemUserTab.tsx:176:27",className:"w-8 h-8 rounded-full bg-blue-600 flex items-center justify-center text-white text-sm font-medium",children:(v.nickname||v.username||"?").charAt(0)}),s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:179:27",children:[s.jsx("p",{"code-path":"src/components/system/SystemUserTab.tsx:180:29",className:"text-sm font-medium text-slate-200",children:v.nickname||v.username}),s.jsxs("p",{"code-path":"src/components/system/SystemUserTab.tsx:181:29",className:"text-xs text-slate-500",children:["@",v.username]})]})]})}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:185:23",children:s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:186:25",className:"space-y-1",children:[s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:187:27",className:"flex items-center gap-1 text-sm text-slate-400",children:[s.jsx(Ue,{"code-path":"src/components/system/SystemUserTab.tsx:188:29",className:"h-3.5 w-3.5"}),v.email||"--"]}),v.phone&&s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:192:29",className:"flex items-center gap-1 text-sm text-slate-400",children:[s.jsx(we,{"code-path":"src/components/system/SystemUserTab.tsx:193:31",className:"h-3.5 w-3.5"}),v.phone]})]})}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:199:23",children:s.jsx("div",{"code-path":"src/components/system/SystemUserTab.tsx:200:25",className:"flex flex-wrap gap-1",children:(v.roles||[]).map(H=>s.jsx(os,{"code-path":"src/components/system/SystemUserTab.tsx:202:29",variant:"outline",className:"border-slate-700 text-slate-400",children:H},H))})}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:208:23",children:v.authSource==="ldap"?s.jsx(os,{"code-path":"src/components/system/SystemUserTab.tsx:210:27",variant:"outline",className:"border-cyan-500/30 text-cyan-400 bg-cyan-500/10",children:"LDAP"}):s.jsx(os,{"code-path":"src/components/system/SystemUserTab.tsx:214:27",variant:"outline",className:"border-slate-600/30 text-slate-400 bg-slate-600/10",children:"本地"})}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:219:23",children:D(v.status)}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:220:23",children:s.jsx("span",{"code-path":"src/components/system/SystemUserTab.tsx:221:25",className:"text-sm text-slate-400",children:v.lastLoginAt?new Date(v.lastLoginAt).toLocaleString():"--"})}),s.jsx(T,{"code-path":"src/components/system/SystemUserTab.tsx:225:23",className:"text-right",children:s.jsxs("div",{"code-path":"src/components/system/SystemUserTab.tsx:226:25",className:"flex items-center justify-end gap-1",children:[s.jsx(i,{"code-path":"src/components/system/SystemUserTab.tsx:227:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:()=>x(v),children:s.jsx(re,{"code-path":"src/components/system/SystemUserTab.tsx:233:29",className:"h-4 w-4"})}),s.jsx(i,{"code-path":"src/components/system/SystemUserTab.tsx:235:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:()=>y(v),children:s.jsx(vs,{"code-path":"src/components/system/SystemUserTab.tsx:241:29",className:"h-4 w-4"})}),s.jsx(i,{"code-path":"src/components/system/SystemUserTab.tsx:243:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-400",onClick:()=>k(v),children:s.jsx(se,{"code-path":"src/components/system/SystemUserTab.tsx:249:29",className:"h-4 w-4"})})]})})]},v.id))})]})})})}),s.jsx(Fe,{"code-path":"src/components/system/SystemUserTab.tsx:263:7",selectedUser:d,setSelectedUser:x,getUserStatusBadge:D,openEdit:y}),s.jsx(Re,{"code-path":"src/components/system/SystemUserTab.tsx:270:7",open:N,onOpenChange:b,editingUser:a,form:u,setForm:I,saving:L,onSubmit:w}),s.jsx(_e,{"code-path":"src/components/system/SystemUserTab.tsx:280:7",importDialogOpen:f,setImportDialogOpen:A,importPreview:F,setImportPreview:E,importing:C,importResult:_,setImportResult:p,handleCsvUpload:O,handleBatchImport:g}),s.jsx(Oe,{"code-path":"src/components/system/SystemUserTab.tsx:292:7",importDialogOpen:f,setImportDialogOpen:A,ldapUsers:$,setLdapUsers:V,ldapSelected:es,setLdapSelected:ts,ldapLoading:W,ldapImportOUs:j,ldapImportOUDN:ls,setLdapImportOUDN:as,loadLdapUsers:rs,handleLdapImport:ds,importing:C,importResult:_,setImportResult:p})]})}function Pe({open:e,onOpenChange:r,editingRole:t,form:n,setForm:d,saving:x,onSubmit:D,permissions:N}){const b=(a,u)=>{d(I=>{const L=new Set(I.permission_ids);return u?L.add(a):L.delete(a),{...I,permission_ids:Array.from(L)}})};return s.jsx(X,{"code-path":"src/components/system/RoleFormDialog.tsx:64:5",open:e,onOpenChange:r,children:s.jsxs(G,{"code-path":"src/components/system/RoleFormDialog.tsx:65:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/RoleFormDialog.tsx:66:9",children:[s.jsxs(Z,{"code-path":"src/components/system/RoleFormDialog.tsx:67:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Us,{"code-path":"src/components/system/RoleFormDialog.tsx:68:13",className:"h-5 w-5 text-purple-400"}),t?"编辑角色":"新建角色"]}),s.jsx(ss,{"code-path":"src/components/system/RoleFormDialog.tsx:71:11",className:"text-slate-500",children:t?"修改角色信息与权限":"创建新的系统角色并分配权限"})]}),s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:76:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:77:11",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:78:13",className:"space-y-2",children:[s.jsx(fs,{"code-path":"src/components/system/RoleFormDialog.tsx:79:15",className:"text-xs text-slate-500",children:"角色名称"}),s.jsx(S,{"code-path":"src/components/system/RoleFormDialog.tsx:80:15",value:n.name,onChange:a=>d({...n,name:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"如:运维工程师"})]}),s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:87:13",className:"space-y-2",children:[s.jsx(fs,{"code-path":"src/components/system/RoleFormDialog.tsx:88:15",className:"text-xs text-slate-500",children:"角色编码"}),s.jsx(S,{"code-path":"src/components/system/RoleFormDialog.tsx:89:15",value:n.code,onChange:a=>d({...n,code:a.target.value}),disabled:!!t,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500 disabled:opacity-60",placeholder:"如:ops_engineer"})]})]}),s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:98:11",className:"space-y-2",children:[s.jsx(fs,{"code-path":"src/components/system/RoleFormDialog.tsx:99:13",className:"text-xs text-slate-500",children:"描述"}),s.jsx(Ce,{"code-path":"src/components/system/RoleFormDialog.tsx:100:13",value:n.description,onChange:a=>d({...n,description:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500 resize-none",placeholder:"角色职责描述(可选)",rows:2})]}),s.jsxs("div",{"code-path":"src/components/system/RoleFormDialog.tsx:108:11",className:"space-y-2",children:[s.jsxs(fs,{"code-path":"src/components/system/RoleFormDialog.tsx:109:13",className:"text-xs text-slate-500",children:["权限分配",n.permission_ids.length>0&&s.jsxs("span",{"code-path":"src/components/system/RoleFormDialog.tsx:112:17",className:"ml-2 text-slate-400",children:["已选 ",n.permission_ids.length," 项"]})]}),s.jsx("div",{"code-path":"src/components/system/RoleFormDialog.tsx:115:13",className:"max-h-48 overflow-y-auto rounded-lg border border-slate-800 bg-slate-800/30 p-3",children:N.length===0?s.jsx("p",{"code-path":"src/components/system/RoleFormDialog.tsx:117:17",className:"text-xs text-slate-500 text-center py-4",children:"暂无可分配权限"}):s.jsx("div",{"code-path":"src/components/system/RoleFormDialog.tsx:119:17",className:"grid grid-cols-2 gap-2",children:N.map(a=>s.jsxs(fs,{"code-path":"src/components/system/RoleFormDialog.tsx:121:21",className:"flex items-center gap-2 text-xs text-slate-300 font-normal cursor-pointer hover:text-slate-100",children:[s.jsx(Me,{"code-path":"src/components/system/RoleFormDialog.tsx:125:23",checked:n.permission_ids.includes(a.id),onCheckedChange:u=>b(a.id,u===!0),className:"border-slate-600 data-[state=checked]:bg-blue-600 data-[state=checked]:border-blue-600"}),s.jsx("span",{"code-path":"src/components/system/RoleFormDialog.tsx:130:23",className:"truncate",children:a.name})]},a.id))})})]})]}),s.jsxs(ms,{"code-path":"src/components/system/RoleFormDialog.tsx:139:9",children:[s.jsx(i,{"code-path":"src/components/system/RoleFormDialog.tsx:140:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>r(!1),children:"取消"}),s.jsx(i,{"code-path":"src/components/system/RoleFormDialog.tsx:143:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:D,disabled:x,children:x?"保存中...":"保存"})]})]})})}function ze(e){const r=Array.isArray(e.permissions)?e.permissions:[];return{id:String(e.id??""),name:e.name??"",code:e.code??"",description:e.description??"",permissions:r.map(t=>typeof t=="string"?t:t?.name??t?.code??"").filter(Boolean),permissionCodes:r.map(t=>typeof t=="string"?t:t?.code??"").filter(Boolean),createdAt:e.createdAt??e.created_at??"",_permissionIds:r.map(t=>typeof t=="object"?Number(t.id):0).filter(Boolean)}}const oe={name:"",code:"",description:"",permission_ids:[]};function Ee({selectedRole:e,setSelectedRole:r}){const t=Xs(),[n,d]=o.useState([]),[x,D]=o.useState(!0),[N,b]=o.useState([]),[a,u]=o.useState(!1),[I,L]=o.useState(null),[w,R]=o.useState({...oe}),[y,k]=o.useState(!1),f=o.useCallback(async()=>{D(!0);try{const O=(await q.getRoles())?.list??[];d(O.map(ze))}catch{d([])}finally{D(!1)}},[]),A=o.useCallback(async()=>{try{const O=(await q.getPermissions())?.list??[];b(O.map(g=>({id:Number(g.id),name:g.name??g.code??"",code:g.code??"",type:g.type})))}catch{b([])}},[]);o.useEffect(()=>{f(),A()},[f,A]);const F=()=>{L(null),R({...oe}),u(!0)},E=p=>{L(p),R({name:p.name??"",code:p.code??"",description:p.description??"",permission_ids:Array.isArray(p._permissionIds)?[...p._permissionIds]:[]}),u(!0)},C=async()=>{if(!w.name.trim()){Q.error("请输入角色名称");return}if(!w.code.trim()){Q.error("请输入角色编码");return}k(!0);try{const p={name:w.name.trim(),code:w.code.trim(),description:w.description.trim(),permission_ids:w.permission_ids};I?(await q.updateRole(I.id,p),Q.success("角色更新成功")):(await q.createRole(p),Q.success("角色创建成功")),u(!1),await f()}catch(p){Q.error(p?.message||"保存失败")}finally{k(!1)}},_=async p=>{if(await t({title:"删除角色",description:`确认删除角色「${p.name}」吗?该操作不可恢复。`,confirmText:"删除",variant:"destructive"}))try{await q.deleteRole(p.id),Q.success("角色已删除"),await f()}catch(g){Q.error(g?.message||"删除失败")}};return s.jsxs(s.Fragment,{children:[s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:171:7",className:"flex items-center justify-end",children:s.jsxs(i,{"code-path":"src/components/system/SystemRolesTab.tsx:172:9",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:F,children:[s.jsx(Zs,{"code-path":"src/components/system/SystemRolesTab.tsx:173:11",className:"h-4 w-4 mr-2"}),"新建角色"]})}),x?s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:179:9",className:"flex items-center justify-center py-16",children:s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:180:11",className:"w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}):n.length===0?s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:183:9",className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[s.jsx(Us,{"code-path":"src/components/system/SystemRolesTab.tsx:184:11",className:"h-10 w-10 mb-3 opacity-40"}),s.jsx("p",{"code-path":"src/components/system/SystemRolesTab.tsx:185:11",className:"text-sm",children:"暂无角色数据"})]}):s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:188:9",className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:n.map(p=>s.jsxs(xs,{"code-path":"src/components/system/SystemRolesTab.tsx:190:13",className:"bg-slate-900 border-slate-800",children:[s.jsx(Ss,{"code-path":"src/components/system/SystemRolesTab.tsx:191:15",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:192:17",className:"flex items-start justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:193:19",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:194:21",className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center",children:s.jsx(Us,{"code-path":"src/components/system/SystemRolesTab.tsx:195:23",className:"h-5 w-5 text-purple-400"})}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:197:21",children:[s.jsx(js,{"code-path":"src/components/system/SystemRolesTab.tsx:198:23",className:"text-base text-slate-100",children:p.name}),s.jsx(us,{"code-path":"src/components/system/SystemRolesTab.tsx:199:23",className:"text-slate-500",children:p.code})]})]}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:202:19",className:"flex items-center gap-1",children:[s.jsx(i,{"code-path":"src/components/system/SystemRolesTab.tsx:203:21",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:()=>r(p),children:s.jsx(re,{"code-path":"src/components/system/SystemRolesTab.tsx:209:23",className:"h-4 w-4"})}),s.jsx(i,{"code-path":"src/components/system/SystemRolesTab.tsx:211:21",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:()=>E(p),children:s.jsx(vs,{"code-path":"src/components/system/SystemRolesTab.tsx:217:23",className:"h-4 w-4"})}),s.jsx(i,{"code-path":"src/components/system/SystemRolesTab.tsx:219:21",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-400",onClick:()=>_(p),children:s.jsx(se,{"code-path":"src/components/system/SystemRolesTab.tsx:225:23",className:"h-4 w-4"})})]})]})}),s.jsxs(hs,{"code-path":"src/components/system/SystemRolesTab.tsx:230:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemRolesTab.tsx:231:17",className:"text-sm text-slate-400 mb-3",children:p.description||"暂无描述"}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:233:17",className:"flex flex-wrap gap-1",children:[p.permissions.slice(0,8).map((O,g)=>s.jsx(os,{"code-path":"src/components/system/SystemRolesTab.tsx:235:21",variant:"outline",className:"border-slate-700 text-slate-400 text-xs",children:O},g)),p.permissions.length>8&&s.jsxs(os,{"code-path":"src/components/system/SystemRolesTab.tsx:240:21",variant:"outline",className:"border-blue-500/30 text-blue-400 text-xs",children:["+",p.permissions.length-8," 项"]}),p.permissions.length===0&&s.jsx("span",{"code-path":"src/components/system/SystemRolesTab.tsx:245:21",className:"text-xs text-slate-600",children:"未分配权限"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:248:17",className:"mt-2 text-xs text-slate-600",children:["共 ",p.permissions?.length||0," 项权限"]})]})]},p.id))}),s.jsx($e,{"code-path":"src/components/system/SystemRolesTab.tsx:258:7",role:e,onClose:()=>r(null),onEdit:p=>{r(null),E(p)}}),s.jsx(Pe,{"code-path":"src/components/system/SystemRolesTab.tsx:261:7",open:a,onOpenChange:u,editingRole:I,form:w,setForm:R,saving:y,onSubmit:C,permissions:N})]})}function $e({role:e,onClose:r,onEdit:t}){return s.jsx(X,{"code-path":"src/components/system/SystemRolesTab.tsx:286:5",open:!!e,onOpenChange:n=>!n&&r(),children:s.jsxs(G,{"code-path":"src/components/system/SystemRolesTab.tsx:287:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/SystemRolesTab.tsx:288:9",children:[s.jsxs(Z,{"code-path":"src/components/system/SystemRolesTab.tsx:289:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Us,{"code-path":"src/components/system/SystemRolesTab.tsx:290:13",className:"h-5 w-5 text-purple-400"}),e?.name]}),s.jsxs(ss,{"code-path":"src/components/system/SystemRolesTab.tsx:293:11",className:"text-slate-500",children:["编码:",e?.code]})]}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:296:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:297:11",className:"rounded-lg bg-slate-800/50 p-4",children:[s.jsx("p",{"code-path":"src/components/system/SystemRolesTab.tsx:298:13",className:"text-xs text-slate-500 mb-1",children:"描述"}),s.jsx("p",{"code-path":"src/components/system/SystemRolesTab.tsx:299:13",className:"text-sm text-slate-200",children:e?.description||"暂无描述"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemRolesTab.tsx:301:11",children:[s.jsxs("h4",{"code-path":"src/components/system/SystemRolesTab.tsx:302:13",className:"text-sm font-medium text-slate-300 mb-2",children:["权限列表 (",e?.permissions?.length||0," 项)"]}),e&&e.permissions.length>0?s.jsx("div",{"code-path":"src/components/system/SystemRolesTab.tsx:304:15",className:"flex flex-wrap gap-2 max-h-60 overflow-y-auto",children:e.permissions.map((n,d)=>s.jsx(os,{"code-path":"src/components/system/SystemRolesTab.tsx:306:19",variant:"outline",className:"border-slate-700 text-slate-300",children:n},d))}):s.jsx("p",{"code-path":"src/components/system/SystemRolesTab.tsx:312:15",className:"text-xs text-slate-500",children:"未分配权限"})]})]}),s.jsx(ms,{"code-path":"src/components/system/SystemRolesTab.tsx:317:9",children:s.jsxs(i,{"code-path":"src/components/system/SystemRolesTab.tsx:318:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>e&&t(e),children:[s.jsx(vs,{"code-path":"src/components/system/SystemRolesTab.tsx:319:13",className:"h-4 w-4 mr-2"}),"编辑"]})})]})})}function Be(e){const{ldapConfig:r,ldapMgmtOpen:t,setLdapMgmtOpen:n,ldapOUs:d,selectedOUDN:x,setSelectedOUDN:D,ldapUsers:N,selectedLDAPUsers:b,setSelectedLDAPUsers:a,loadLdapOUs:u,loadLdapOUUsers:I,handleLdapImport:L,importing:w,importFeedback:R,importResultOpen:y,setImportResultOpen:k,createOUOpen:f,setCreateOUOpen:A,ouForm:F,setOuForm:E,handleCreateOU:C,ldapSaving:_,createUserOpen:p,setCreateUserOpen:O,newUser:g,setNewUser:$,handleCreateLDAPUser:es,ldapUserTestOpen:ts,setLdapUserTestOpen:W,ldapTestUser:j,setLdapTestUser:ls,ldapTestPass:as,setLdapTestPass:rs,ldapUserTesting:ds,ldapUserTestResult:V,handleLdapUserTest:v,editLdapUser:H,setEditLdapUser:ps,editLdapForm:l,setEditLdapForm:P,handleUpdateLdapUser:cs,handleDeleteLDAPEntry:Ts,openEditLdapUser:ks}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("button",{"code-path":"src/components/system/LdapManagementSection.tsx:140:7",onClick:()=>{const c=!t;n(c),c&&d.length===0&&u()},className:"w-full flex items-center gap-2 px-4 py-2.5 bg-slate-900/50 hover:bg-slate-800/50 text-slate-400 text-sm transition-colors",children:[s.jsx(ve,{"code-path":"src/components/system/LdapManagementSection.tsx:148:9",className:`h-4 w-4 transition-transform ${t?"":"-rotate-90"}`}),s.jsx(de,{"code-path":"src/components/system/LdapManagementSection.tsx:149:9",className:"h-4 w-4 text-amber-400"}),s.jsx("span",{"code-path":"src/components/system/LdapManagementSection.tsx:150:9",className:"text-slate-300",children:"LDAP 账号管理"})]}),t&&s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:154:9",className:"bg-slate-900/30 border-t border-slate-800/50 px-4 py-4 space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:155:11",className:"flex items-center gap-3 flex-wrap",children:[s.jsxs(X,{"code-path":"src/components/system/LdapManagementSection.tsx:157:13",open:ts,onOpenChange:W,children:[s.jsx(Vs,{"code-path":"src/components/system/LdapManagementSection.tsx:158:15",asChild:!0,children:s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:159:17",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-200",children:[s.jsx(qs,{"code-path":"src/components/system/LdapManagementSection.tsx:160:19",className:"h-3.5 w-3.5 mr-1"}),"账号验证"]})}),s.jsxs(G,{"code-path":"src/components/system/LdapManagementSection.tsx:164:15",className:"max-w-md bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapManagementSection.tsx:165:17",children:[s.jsx(Z,{"code-path":"src/components/system/LdapManagementSection.tsx:166:19",className:"text-slate-100",children:"LDAP 账号验证测试"}),s.jsx(ss,{"code-path":"src/components/system/LdapManagementSection.tsx:167:19",className:"text-slate-500",children:"输入 LDAP 用户凭据进行认证测试"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:169:17",className:"space-y-3 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:170:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:171:21",className:"text-xs text-slate-500 mb-1 block",children:"用户名"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:172:21",value:j,onChange:c=>ls(c.target.value),placeholder:"zhangsan",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:179:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:180:21",className:"text-xs text-slate-500 mb-1 block",children:"密码"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:181:21",type:"password",value:as,onChange:c=>rs(c.target.value),onKeyDown:c=>c.key==="Enter"&&v(),placeholder:"••••••",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600"})]}),V&&s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:191:21",className:`p-3 rounded-lg text-sm ${V.success?"bg-emerald-500/10 text-emerald-300":"bg-red-500/10 text-red-300"}`,children:[V.message,V.user_info&&s.jsx("pre",{"code-path":"src/components/system/LdapManagementSection.tsx:194:25",className:"mt-2 text-xs whitespace-pre-wrap",children:JSON.stringify(V.user_info,null,2)})]}),s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:198:19",className:"w-full bg-blue-600 hover:bg-blue-700 text-white",onClick:v,disabled:ds||!j,children:[ds?s.jsx(Ns,{"code-path":"src/components/system/LdapManagementSection.tsx:203:40",className:"h-4 w-4 mr-1.5 animate-spin"}):null,"验证"]})]})]})]}),s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:210:13",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-200",onClick:u,children:[s.jsx(Ys,{"code-path":"src/components/system/LdapManagementSection.tsx:211:15",className:"h-3.5 w-3.5 mr-1"}),"刷新"]}),s.jsxs(ws,{"code-path":"src/components/system/LdapManagementSection.tsx:216:13",value:x,onValueChange:c=>{D(c),I(c)},children:[s.jsx(Cs,{"code-path":"src/components/system/LdapManagementSection.tsx:217:15",className:"w-60 h-7 bg-slate-800 border-slate-700 text-slate-200 text-xs",children:s.jsx(Ms,{"code-path":"src/components/system/LdapManagementSection.tsx:218:17",placeholder:"选择组织单元"})}),s.jsxs(Is,{"code-path":"src/components/system/LdapManagementSection.tsx:220:15",className:"bg-slate-800 border-slate-700",children:[s.jsxs(B,{"code-path":"src/components/system/LdapManagementSection.tsx:221:17",value:r.base_dn,children:["根 (",r.base_dn,")"]}),d.map(c=>s.jsx(B,{"code-path":"src/components/system/LdapManagementSection.tsx:223:19",value:c.dn,children:c.description?`${c.name} (${c.description})`:c.name},c.dn))]})]}),s.jsxs(X,{"code-path":"src/components/system/LdapManagementSection.tsx:231:13",open:f,onOpenChange:A,children:[s.jsx(Vs,{"code-path":"src/components/system/LdapManagementSection.tsx:232:15",asChild:!0,children:s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:233:17",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-200",children:[s.jsx(Zs,{"code-path":"src/components/system/LdapManagementSection.tsx:234:19",className:"h-3.5 w-3.5 mr-1"}),"新建 OU"]})}),s.jsxs(G,{"code-path":"src/components/system/LdapManagementSection.tsx:238:15",className:"max-w-md bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapManagementSection.tsx:239:17",children:[s.jsx(Z,{"code-path":"src/components/system/LdapManagementSection.tsx:240:19",className:"text-slate-100",children:"新建组织单元"}),s.jsx(ss,{"code-path":"src/components/system/LdapManagementSection.tsx:241:19",className:"text-slate-500",children:"在 LDAP 目录中创建新的组织单元 (OU)"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:243:17",className:"space-y-3 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:244:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:245:21",className:"text-xs text-slate-500 mb-1 block",children:"OU 名称 *"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:246:21",value:F.ou_name,onChange:c=>E({...F,ou_name:c.target.value}),placeholder:"dev",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:248:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:249:21",className:"text-xs text-slate-500 mb-1 block",children:"父级 DN"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:250:21",value:F.parent_dn,onChange:c=>E({...F,parent_dn:c.target.value}),placeholder:r.base_dn,className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:252:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:253:21",className:"text-xs text-slate-500 mb-1 block",children:"描述"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:254:21",value:F.description,onChange:c=>E({...F,description:c.target.value}),placeholder:"开发团队",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:256:19",className:"w-full bg-blue-600 hover:bg-blue-700 text-white",onClick:C,disabled:!F.ou_name||_,children:[_?s.jsx(Ns,{"code-path":"src/components/system/LdapManagementSection.tsx:257:35",className:"h-4 w-4 mr-1.5 animate-spin"}):null,"创建"]})]})]})]}),s.jsxs(X,{"code-path":"src/components/system/LdapManagementSection.tsx:265:13",open:p,onOpenChange:O,children:[s.jsx(Vs,{"code-path":"src/components/system/LdapManagementSection.tsx:266:15",asChild:!0,children:s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:267:17",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-200",children:[s.jsx(Ie,{"code-path":"src/components/system/LdapManagementSection.tsx:268:19",className:"h-3.5 w-3.5 mr-1"}),"添加用户"]})}),s.jsxs(G,{"code-path":"src/components/system/LdapManagementSection.tsx:272:15",className:"max-w-md bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapManagementSection.tsx:273:17",children:[s.jsx(Z,{"code-path":"src/components/system/LdapManagementSection.tsx:274:19",className:"text-slate-100",children:"添加 LDAP 用户"}),s.jsx(ss,{"code-path":"src/components/system/LdapManagementSection.tsx:275:19",className:"text-slate-500",children:"在 LDAP 目录中创建新的用户账号"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:277:17",className:"space-y-3 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:278:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:279:21",className:"text-xs text-slate-500 mb-1 block",children:"用户名 *"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:280:21",value:g.username,onChange:c=>$({...g,username:c.target.value}),placeholder:"zhangsan",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:282:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:283:21",className:"text-xs text-slate-500 mb-1 block",children:"密码 *"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:284:21",type:"password",value:g.password,onChange:c=>$({...g,password:c.target.value}),placeholder:"••••••",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:286:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:287:21",className:"text-xs text-slate-500 mb-1 block",children:"显示名称"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:288:21",value:g.display_name,onChange:c=>$({...g,display_name:c.target.value}),placeholder:"张三",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:290:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:291:21",className:"text-xs text-slate-500 mb-1 block",children:"邮箱"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:292:21",value:g.email,onChange:c=>$({...g,email:c.target.value}),placeholder:"zs@example.com",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:294:19",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:295:21",className:"text-xs text-slate-500 mb-1 block",children:"目标 OU"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:296:21",value:g.ou_dn||x||r.base_dn,onChange:c=>$({...g,ou_dn:c.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:298:19",className:"w-full bg-blue-600 hover:bg-blue-700 text-white",onClick:es,disabled:!g.username||!g.password||_,children:[_?s.jsx(Ns,{"code-path":"src/components/system/LdapManagementSection.tsx:299:35",className:"h-4 w-4 mr-1.5 animate-spin"}):null,"创建"]})]})]})]}),s.jsxs(i,{"code-path":"src/components/system/LdapManagementSection.tsx:307:13",variant:"outline",size:"sm",className:"border-blue-600/50 text-blue-400 hover:bg-blue-600/10 ml-auto",onClick:L,disabled:N.length===0||w,children:[w?s.jsx(Ns,{"code-path":"src/components/system/LdapManagementSection.tsx:314:28",className:"h-3.5 w-3.5 mr-1 animate-spin"}):s.jsx(ie,{"code-path":"src/components/system/LdapManagementSection.tsx:314:84",className:"h-3.5 w-3.5 mr-1"}),b.length>0?`导入 (${b.length})`:`导入全部 (${N.length})`]})]}),R&&s.jsx(X,{"code-path":"src/components/system/LdapManagementSection.tsx:320:13",open:y,onOpenChange:k,children:s.jsxs(G,{"code-path":"src/components/system/LdapManagementSection.tsx:321:15",className:"max-w-sm bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapManagementSection.tsx:322:17",children:[s.jsx(Z,{"code-path":"src/components/system/LdapManagementSection.tsx:323:19",className:"text-slate-100",children:"导入结果"}),s.jsx(ss,{"code-path":"src/components/system/LdapManagementSection.tsx:324:19",className:"text-slate-500",children:"LDAP 用户导入到本地用户库的执行结果"})]}),s.jsx("div",{"code-path":"src/components/system/LdapManagementSection.tsx:326:17",className:"py-3 text-sm text-slate-300",children:R}),s.jsx(i,{"code-path":"src/components/system/LdapManagementSection.tsx:329:17",className:"w-full bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>k(!1),children:"确定"})]})}),s.jsx("div",{"code-path":"src/components/system/LdapManagementSection.tsx:337:11",className:"border border-slate-800 rounded-lg overflow-hidden",children:s.jsxs(Ps,{"code-path":"src/components/system/LdapManagementSection.tsx:338:13",children:[s.jsx(zs,{"code-path":"src/components/system/LdapManagementSection.tsx:339:15",children:s.jsxs(J,{"code-path":"src/components/system/LdapManagementSection.tsx:340:17",className:"border-slate-800 hover:bg-transparent",children:[s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:341:19",className:"text-slate-400 w-8",children:s.jsx("input",{"code-path":"src/components/system/LdapManagementSection.tsx:342:21",type:"checkbox",className:"rounded bg-slate-800 border-slate-600",checked:b.length>0&&b.length===N.length,onChange:c=>a(c.target.checked?N.map(K=>K.dn):[])})}),s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:349:19",className:"text-slate-400",children:"用户名"}),s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:350:19",className:"text-slate-400",children:"显示名称"}),s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:351:19",className:"text-slate-400",children:"邮箱"}),s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:352:19",className:"text-slate-400",children:"DN"}),s.jsx(U,{"code-path":"src/components/system/LdapManagementSection.tsx:353:19",className:"text-slate-400 w-12",children:"操作"})]})}),s.jsx(Es,{"code-path":"src/components/system/LdapManagementSection.tsx:356:15",children:N.length===0?s.jsx(J,{"code-path":"src/components/system/LdapManagementSection.tsx:358:19",className:"border-slate-800",children:s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:359:21",colSpan:6,className:"text-center text-slate-500 py-8",children:"点击「刷新」加载 LDAP 用户"})}):N.map(c=>s.jsxs(J,{"code-path":"src/components/system/LdapManagementSection.tsx:365:21",className:"border-slate-800 hover:bg-slate-800/50",children:[s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:366:23",children:s.jsx("input",{"code-path":"src/components/system/LdapManagementSection.tsx:367:25",type:"checkbox",className:"rounded bg-slate-800 border-slate-600",checked:b.includes(c.dn),onChange:K=>{K.target.checked?a([...b,c.dn]):a(b.filter(is=>is!==c.dn))}})}),s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:377:23",children:s.jsx("span",{"code-path":"src/components/system/LdapManagementSection.tsx:378:25",className:"text-sm text-slate-200 font-medium",children:c.uid})}),s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:380:23",children:s.jsx("span",{"code-path":"src/components/system/LdapManagementSection.tsx:381:25",className:"text-sm text-slate-300",children:c.cn})}),s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:383:23",children:s.jsx("span",{"code-path":"src/components/system/LdapManagementSection.tsx:384:25",className:"text-sm text-slate-400",children:c.mail||"-"})}),s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:386:23",children:s.jsx("code",{"code-path":"src/components/system/LdapManagementSection.tsx:387:25",className:"text-xs text-slate-500",children:c.dn})}),s.jsx(T,{"code-path":"src/components/system/LdapManagementSection.tsx:389:23",children:s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:390:25",className:"flex items-center gap-1",children:[s.jsx(i,{"code-path":"src/components/system/LdapManagementSection.tsx:391:27",variant:"ghost",size:"icon",className:"h-6 w-6 text-slate-400 hover:text-blue-400 hover:bg-blue-500/10",onClick:()=>ks(c),children:s.jsx(vs,{"code-path":"src/components/system/LdapManagementSection.tsx:397:29",className:"h-3 w-3"})}),s.jsx(i,{"code-path":"src/components/system/LdapManagementSection.tsx:399:27",variant:"ghost",size:"icon",className:"h-6 w-6 text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Ts(c.dn),children:s.jsx(se,{"code-path":"src/components/system/LdapManagementSection.tsx:405:29",className:"h-3 w-3"})})]})})]},c.dn))})]})})]}),s.jsx(X,{"code-path":"src/components/system/LdapManagementSection.tsx:419:7",open:!!H,onOpenChange:c=>!c&&ps(null),children:s.jsxs(G,{"code-path":"src/components/system/LdapManagementSection.tsx:420:9",className:"max-w-md bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/LdapManagementSection.tsx:421:11",children:[s.jsxs(Z,{"code-path":"src/components/system/LdapManagementSection.tsx:422:13",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(vs,{"code-path":"src/components/system/LdapManagementSection.tsx:423:15",className:"h-5 w-5 text-blue-400"}),"编辑 LDAP 用户"]}),s.jsxs(ss,{"code-path":"src/components/system/LdapManagementSection.tsx:426:13",className:"text-slate-500",children:["修改 ",H?.uid," 的属性"]})]}),H&&s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:431:13",className:"space-y-3 py-2",children:[s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:432:15",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:433:17",className:"text-xs text-slate-500 mb-1 block",children:"用户名(只读)"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:434:17",value:H.uid||"",disabled:!0,className:"bg-slate-800/50 border-slate-700 text-slate-500"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:436:15",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:437:17",className:"text-xs text-slate-500 mb-1 block",children:"显示名称 (cn)"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:438:17",value:l.cn,onChange:c=>P({...l,cn:c.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:440:15",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:441:17",className:"text-xs text-slate-500 mb-1 block",children:"邮箱"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:442:17",value:l.mail,onChange:c=>P({...l,mail:c.target.value}),placeholder:"user@example.com",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:444:15",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:445:17",className:"text-xs text-slate-500 mb-1 block",children:"电话"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:446:17",value:l.phone,onChange:c=>P({...l,phone:c.target.value}),placeholder:"13800138000",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]}),s.jsxs("div",{"code-path":"src/components/system/LdapManagementSection.tsx:448:15",children:[s.jsx("label",{"code-path":"src/components/system/LdapManagementSection.tsx:449:17",className:"text-xs text-slate-500 mb-1 block",children:"职位/头衔"}),s.jsx(S,{"code-path":"src/components/system/LdapManagementSection.tsx:450:17",value:l.title,onChange:c=>P({...l,title:c.target.value}),placeholder:"运维工程师",className:"bg-slate-800/50 border-slate-700 text-slate-200"})]})]}),s.jsxs(ms,{"code-path":"src/components/system/LdapManagementSection.tsx:454:11",children:[s.jsx(i,{"code-path":"src/components/system/LdapManagementSection.tsx:455:13",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>ps(null),children:"取消"}),s.jsx(i,{"code-path":"src/components/system/LdapManagementSection.tsx:456:13",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:cs,children:"保存"})]})]})})]})}function Ve(e){const{ldapConfig:r,ldapForm:t,setLdapForm:n,ldapSaving:d,ldapTesting:x,ldapTestResult:D,handleLdapSave:N,handleLdapTest:b}=e;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:93:7",className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[s.jsxs(xs,{"code-path":"src/components/system/SystemSettingsTab.tsx:94:9",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Ss,{"code-path":"src/components/system/SystemSettingsTab.tsx:95:11",children:[s.jsxs(js,{"code-path":"src/components/system/SystemSettingsTab.tsx:96:13",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Te,{"code-path":"src/components/system/SystemSettingsTab.tsx:97:15",className:"h-5 w-5 text-blue-400"}),"安全设置"]}),s.jsx(us,{"code-path":"src/components/system/SystemSettingsTab.tsx:100:13",className:"text-slate-500",children:"密码策略与登录安全"})]}),s.jsxs(hs,{"code-path":"src/components/system/SystemSettingsTab.tsx:102:11",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:103:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:104:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:105:17",className:"text-sm font-medium text-slate-200",children:"强制密码复杂度"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:106:17",className:"text-xs text-slate-500",children:"要求密码包含大小写字母、数字和特殊字符"})]}),s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:108:15",defaultChecked:!0,className:"data-[state=checked]:bg-blue-600"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:110:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:111:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:112:17",className:"text-sm font-medium text-slate-200",children:"登录失败锁定"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:113:17",className:"text-xs text-slate-500",children:"连续5次登录失败锁定账户30分钟"})]}),s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:115:15",defaultChecked:!0,className:"data-[state=checked]:bg-blue-600"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:117:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:118:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:119:17",className:"text-sm font-medium text-slate-200",children:"双因素认证"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:120:17",className:"text-xs text-slate-500",children:"启用后需要手机验证码登录"})]}),s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:122:15",className:"data-[state=checked]:bg-blue-600"})]})]})]}),s.jsxs(xs,{"code-path":"src/components/system/SystemSettingsTab.tsx:127:9",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Ss,{"code-path":"src/components/system/SystemSettingsTab.tsx:128:11",children:[s.jsxs(js,{"code-path":"src/components/system/SystemSettingsTab.tsx:129:13",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(ke,{"code-path":"src/components/system/SystemSettingsTab.tsx:130:15",className:"h-5 w-5 text-emerald-400"}),"审计设置"]}),s.jsx(us,{"code-path":"src/components/system/SystemSettingsTab.tsx:133:13",className:"text-slate-500",children:"操作日志与审计策略"})]}),s.jsxs(hs,{"code-path":"src/components/system/SystemSettingsTab.tsx:135:11",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:136:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:137:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:138:17",className:"text-sm font-medium text-slate-200",children:"记录所有操作"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:139:17",className:"text-xs text-slate-500",children:"记录用户的所有操作行为"})]}),s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:141:15",defaultChecked:!0,className:"data-[state=checked]:bg-blue-600"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:143:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:144:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:145:17",className:"text-sm font-medium text-slate-200",children:"日志保留时间"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:146:17",className:"text-xs text-slate-500",children:"操作日志保留180天"})]}),s.jsxs(ws,{"code-path":"src/components/system/SystemSettingsTab.tsx:148:15",defaultValue:"180",children:[s.jsx(Cs,{"code-path":"src/components/system/SystemSettingsTab.tsx:149:17",className:"w-32 h-8 bg-slate-800 border-slate-700 text-slate-200",children:s.jsx(Ms,{"code-path":"src/components/system/SystemSettingsTab.tsx:150:19"})}),s.jsxs(Is,{"code-path":"src/components/system/SystemSettingsTab.tsx:152:17",className:"bg-slate-800 border-slate-700",children:[s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:153:19",value:"30",children:"30天"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:154:19",value:"90",children:"90天"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:155:19",value:"180",children:"180天"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:156:19",value:"365",children:"1年"})]})]})]})]})]}),s.jsxs(xs,{"code-path":"src/components/system/SystemSettingsTab.tsx:163:9",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Ss,{"code-path":"src/components/system/SystemSettingsTab.tsx:164:11",children:[s.jsxs(js,{"code-path":"src/components/system/SystemSettingsTab.tsx:165:13",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(qs,{"code-path":"src/components/system/SystemSettingsTab.tsx:166:15",className:"h-5 w-5 text-amber-400"}),"会话设置"]}),s.jsx(us,{"code-path":"src/components/system/SystemSettingsTab.tsx:169:13",className:"text-slate-500",children:"会话超时与Token配置"})]}),s.jsxs(hs,{"code-path":"src/components/system/SystemSettingsTab.tsx:171:11",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:172:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:173:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:174:17",className:"text-sm font-medium text-slate-200",children:"会话超时时间"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:175:17",className:"text-xs text-slate-500",children:"用户无操作30分钟后自动登出"})]}),s.jsxs(ws,{"code-path":"src/components/system/SystemSettingsTab.tsx:177:15",defaultValue:"30",children:[s.jsx(Cs,{"code-path":"src/components/system/SystemSettingsTab.tsx:178:17",className:"w-32 h-8 bg-slate-800 border-slate-700 text-slate-200",children:s.jsx(Ms,{"code-path":"src/components/system/SystemSettingsTab.tsx:179:19"})}),s.jsxs(Is,{"code-path":"src/components/system/SystemSettingsTab.tsx:181:17",className:"bg-slate-800 border-slate-700",children:[s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:182:19",value:"15",children:"15分钟"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:183:19",value:"30",children:"30分钟"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:184:19",value:"60",children:"1小时"}),s.jsx(B,{"code-path":"src/components/system/SystemSettingsTab.tsx:185:19",value:"120",children:"2小时"})]})]})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:189:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:190:15",children:[s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:191:17",className:"text-sm font-medium text-slate-200",children:"单点登录"}),s.jsx("p",{"code-path":"src/components/system/SystemSettingsTab.tsx:192:17",className:"text-xs text-slate-500",children:"同一账号只能在一个设备登录"})]}),s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:194:15",className:"data-[state=checked]:bg-blue-600"})]})]})]}),s.jsxs(xs,{"code-path":"src/components/system/SystemSettingsTab.tsx:199:9",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Ss,{"code-path":"src/components/system/SystemSettingsTab.tsx:200:11",children:[s.jsxs(js,{"code-path":"src/components/system/SystemSettingsTab.tsx:201:13",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(pe,{"code-path":"src/components/system/SystemSettingsTab.tsx:202:15",className:"h-5 w-5 text-purple-400"}),"系统信息"]}),s.jsx(us,{"code-path":"src/components/system/SystemSettingsTab.tsx:205:13",className:"text-slate-500",children:"版本与系统状态"})]}),s.jsxs(hs,{"code-path":"src/components/system/SystemSettingsTab.tsx:207:11",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:208:13",className:"flex items-center justify-between",children:[s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:209:15",className:"text-sm text-slate-400",children:"系统版本"}),s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:210:15",className:"text-sm text-slate-200",children:"v2.5.1"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:212:13",className:"flex items-center justify-between",children:[s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:213:15",className:"text-sm text-slate-400",children:"运行时间"}),s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:214:15",className:"text-sm text-slate-200",children:"30天 12小时"})]})]})]})]}),s.jsxs(xs,{"code-path":"src/components/system/SystemSettingsTab.tsx:221:7",className:"bg-slate-900 border-slate-800 mt-4",children:[s.jsx(Ss,{"code-path":"src/components/system/SystemSettingsTab.tsx:222:9",children:s.jsx("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:223:11",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:224:13",children:[s.jsxs(js,{"code-path":"src/components/system/SystemSettingsTab.tsx:225:15",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(Ws,{"code-path":"src/components/system/SystemSettingsTab.tsx:226:17",className:"h-5 w-5 text-cyan-400"}),"LDAP / Active Directory"]}),s.jsx(us,{"code-path":"src/components/system/SystemSettingsTab.tsx:229:15",className:"text-slate-500 mt-1",children:"配置 LDAP 服务器,实现统一身份认证"})]})})}),s.jsxs(hs,{"code-path":"src/components/system/SystemSettingsTab.tsx:233:9",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:234:11",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:235:13",className:"space-y-1.5",children:[s.jsx("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:236:15",className:"text-xs text-slate-500",children:"LDAP 服务器地址"}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:237:15",value:t.ldap_host,onChange:a=>n({...t,ldap_host:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600",placeholder:"ldap.example.com"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:244:13",className:"space-y-1.5",children:[s.jsx("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:245:15",className:"text-xs text-slate-500",children:"端口"}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:246:15",type:"number",value:t.ldap_port,onChange:a=>n({...t,ldap_port:Number(a.target.value)}),className:"bg-slate-800/50 border-slate-700 text-slate-200",placeholder:"389"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:254:13",className:"space-y-1.5 col-span-2",children:[s.jsx("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:255:15",className:"text-xs text-slate-500",children:"Base DN(用户搜索基础)"}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:256:15",value:t.base_dn,onChange:a=>n({...t,base_dn:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600",placeholder:"ou=users,dc=example,dc=com"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:263:13",className:"space-y-1.5",children:[s.jsx("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:264:15",className:"text-xs text-slate-500",children:"管理员 Bind DN"}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:265:15",value:t.admin_dn,onChange:a=>n({...t,admin_dn:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600",placeholder:"cn=admin,dc=example,dc=com"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:272:13",className:"space-y-1.5",children:[s.jsxs("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:273:15",className:"text-xs text-slate-500",children:["管理员密码 ",r&&"(留空不修改)"]}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:274:15",type:"password",value:t.admin_password,onChange:a=>n({...t,admin_password:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600",placeholder:"******"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:282:13",className:"space-y-1.5 col-span-2",children:[s.jsx("label",{"code-path":"src/components/system/SystemSettingsTab.tsx:283:15",className:"text-xs text-slate-500",children:"搜索过滤器(可选,用 %s 代表用户名)"}),s.jsx(S,{"code-path":"src/components/system/SystemSettingsTab.tsx:284:15",value:t.search_filter,onChange:a=>n({...t,search_filter:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600",placeholder:"(uid=%s)"})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:291:13",className:"flex items-center gap-2 col-span-2",children:[s.jsx(bs,{"code-path":"src/components/system/SystemSettingsTab.tsx:292:15",checked:t.use_ldaps,onCheckedChange:a=>n({...t,use_ldaps:a}),className:"data-[state=checked]:bg-blue-600"}),s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:297:15",className:"text-sm text-slate-300",children:"启用 LDAPS(SSL 加密)"})]})]}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:302:11",className:"flex items-center gap-3 mt-4 pt-4 border-t border-slate-800",children:[D&&s.jsx("span",{"code-path":"src/components/system/SystemSettingsTab.tsx:304:15",className:`text-xs ${D.includes("成功")?"text-emerald-400":"text-red-400"}`,children:D}),s.jsxs("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:308:13",className:"flex items-center gap-2 ml-auto",children:[s.jsxs(i,{"code-path":"src/components/system/SystemSettingsTab.tsx:309:15",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:b,disabled:x,children:[x?s.jsx(Ns,{"code-path":"src/components/system/SystemSettingsTab.tsx:316:32",className:"h-3.5 w-3.5 mr-1 animate-spin"}):s.jsx(Ys,{"code-path":"src/components/system/SystemSettingsTab.tsx:316:88",className:"h-3.5 w-3.5 mr-1"}),"测试连接"]}),s.jsx(i,{"code-path":"src/components/system/SystemSettingsTab.tsx:319:15",size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:N,disabled:d,children:d?"保存中...":"保存配置"})]})]})]})]}),r&&s.jsx("div",{"code-path":"src/components/system/SystemSettingsTab.tsx:334:9",className:"mt-4",children:s.jsx(Be,{"code-path":"src/components/system/SystemSettingsTab.tsx:335:11",...e})})]})}function He(e){const r=Xs(),[t,n]=o.useState([]),[d,x]=o.useState(new Set),[D,N]=o.useState(!1),[b,a]=o.useState([]),[u,I]=o.useState(""),[L,w]=o.useState(null),[R,y]=o.useState({ldap_host:"",ldap_port:389,use_ldaps:!1,admin_dn:"",admin_password:"",base_dn:"",search_filter:""}),[k,f]=o.useState(!1),[A,F]=o.useState(!1),[E,C]=o.useState(null),[_,p]=o.useState(!1),[O,g]=o.useState(null),[$,es]=o.useState(!1),[ts,W]=o.useState([]),[j,ls]=o.useState(""),[as,rs]=o.useState([]),[ds,V]=o.useState(!1),[v,H]=o.useState(!1),[ps,l]=o.useState({ou_name:"",parent_dn:"",description:""}),[P,cs]=o.useState({username:"",password:"",display_name:"",email:"",ou_dn:""}),[Ts,ks]=o.useState(!1),[c,K]=o.useState(""),[is,Rs]=o.useState(""),[Fs,Ls]=o.useState(!1),[_s,ys]=o.useState(null),[gs,h]=o.useState(null),[ns,Os]=o.useState({cn:"",mail:"",phone:"",title:""}),[ee,$s]=o.useState(!1),te=async()=>{try{const m=await z.getConfig();m&&m.ldap_host&&(w(m),y({ldap_host:m.ldap_host||"",ldap_port:m.ldap_port||389,use_ldaps:m.use_ldaps||!1,admin_dn:m.admin_dn||"",admin_password:"",base_dn:m.base_dn||"",search_filter:m.search_filter||""}))}catch{}},xe=async()=>{f(!0);try{await z.updateConfig(R),await te()}catch(m){console.error("Failed to save LDAP config:",m)}finally{f(!1)}},he=async()=>{F(!0),C(null);try{await z.updateConfig(R);const m=await z.testConnection();C(m?.message||(m?.success?"连接成功":"连接失败"))}catch(m){C(m?.message||"连接失败")}finally{F(!1)}},Ds=async m=>{try{const M=await z.listUsers(m);n(M||[])}catch(M){console.error("loadOUUsers",M)}},ae=async()=>{try{const m=await z.listOUs();W(m||[]),!j&&L?.base_dn&&(ls(L.base_dn),await Ds(L.base_dn))}catch(m){console.error("loadOUs",m)}},ye=async()=>{f(!0);try{await z.createOU(ps),V(!1),l({ou_name:"",parent_dn:"",description:""}),await ae()}catch(m){const M=m?.message||"";M.includes("Already Exists")||M.includes("68")?Q.error(`OU "${ps.ou_name}" 已存在,请使用其他名称`):Q.error("创建失败: "+M)}finally{f(!1)}},ge=async()=>{f(!0);try{await z.createUser({...P,ou_dn:P.ou_dn||j||L?.base_dn}),H(!1),cs({username:"",password:"",display_name:"",email:"",ou_dn:""}),await Ds(j)}catch(m){Q.error(m?.message||"创建失败")}finally{f(!1)}},be=async(m,M=!1)=>{if(!(!M&&!await r({title:"删除 LDAP 条目",description:`确定删除 ${m}?`,confirmText:"删除",variant:"destructive"})))try{await z.deleteUser(m),M||await Ds(j)}catch(As){M||Q.error(As?.message||"删除失败")}},Se=m=>{h(m),Os({cn:m.cn||"",mail:m.mail||"",phone:m.phone||"",title:m.title||""})},je=async()=>{if(gs)try{await z.updateUser({dn:gs.dn,...ns}),h(null),await Ds(j)}catch(m){Q.error(m?.message||"修改失败")}},ue=async()=>{Ls(!0),ys(null);try{const m=await z.testConnection({test_user:c,test_password:is});ys(m)}catch(m){ys({success:!1,message:m?.message||"验证失败"})}finally{Ls(!1)}},ce=async m=>{N(!0);try{const M=await z.listUsers(m);n(Array.isArray(M)?M:[]),x(new Set)}catch{n([])}finally{N(!1)}},ne=async()=>{let m=[];if(as.length>0?m=t.filter(M=>as.includes(M.dn)):m=t,m.length!==0){$s(!0);try{const M=m.map(Bs=>({username:Bs.uid||"",nickname:Bs.cn||"",email:Bs.mail||""})),As=await z.batchImport(M);g(As?.message||`成功导入 ${m.length} 个用户`),es(!0),rs([]),await e()}catch(M){g("导入失败: "+(M?.message||"未知错误")),es(!0)}finally{$s(!1)}}};return{ldapUsers:t,setLdapUsers:n,ldapSelected:d,setLdapSelected:x,ldapLoading:D,ldapImportOUs:b,ldapImportOUDN:u,setLdapImportOUDN:I,loadLdapUsers:ce,handleLdapImport:ne,loadImportDialogData:()=>{z.listOUs().then(m=>a(Array.isArray(m)?m:[])).catch(()=>{}),ce("")},importing:ee,setImporting:$s,importFeedback:O,importResultOpen:$,setImportResultOpen:es,loadLdapConfig:te,settingsTabProps:{ldapConfig:L,ldapForm:R,setLdapForm:y,ldapSaving:k,ldapTesting:A,ldapTestResult:E,handleLdapSave:xe,handleLdapTest:he,ldapMgmtOpen:_,setLdapMgmtOpen:p,ldapOUs:ts,selectedOUDN:j,setSelectedOUDN:ls,ldapUsers:t,selectedLDAPUsers:as,setSelectedLDAPUsers:rs,loadLdapOUs:ae,loadLdapOUUsers:Ds,handleLdapImport:ne,importing:ee,importFeedback:O,importResultOpen:$,setImportResultOpen:es,createOUOpen:ds,setCreateOUOpen:V,ouForm:ps,setOuForm:l,handleCreateOU:ye,createUserOpen:v,setCreateUserOpen:H,newUser:P,setNewUser:cs,handleCreateLDAPUser:ge,ldapUserTestOpen:Ts,setLdapUserTestOpen:ks,ldapTestUser:c,setLdapTestUser:K,ldapTestPass:is,setLdapTestPass:Rs,ldapUserTesting:Fs,ldapUserTestResult:_s,handleLdapUserTest:ue,editLdapUser:gs,setEditLdapUser:h,editLdapForm:ns,setEditLdapForm:Os,handleUpdateLdapUser:je,handleDeleteLDAPEntry:be,openEditLdapUser:Se}}}function Ke(e){return{...e,status:e.status===1||e.status==="active"?"active":"inactive",roles:Array.isArray(e.roles)?e.roles:e.role?[e.role]:[],lastLoginAt:e.last_login??e.lastLoginAt,createdAt:e.created_at??e.createdAt,authSource:e.auth_source??e.authSource??"local"}}const me={username:"",nickname:"",email:"",phone:"",role:"",password:"",status:1};function gt(){const e=Xs(),r=Le(),t={"/users":"users","/roles":"roles","/settings":"settings"},[n,d]=o.useState(t[r.pathname]||"users");o.useEffect(()=>{const l=t[r.pathname];l&&l!==n&&d(l)},[r.pathname]);const[x,D]=o.useState(""),[N,b]=o.useState([]),[a,u]=o.useState(!0),[I,L]=o.useState(null),[w,R]=o.useState(null),[y,k]=o.useState(!1),[f,A]=o.useState(null),[F,E]=o.useState(!1),[C,_]=o.useState({...me}),[p,O]=o.useState(null),[g,$]=o.useState([]),[es,ts]=o.useState(null),W=async()=>{u(!0);try{const P=(await q.getUsers({page:1,page_size:100}))?.list??[];b(P.map(Ke))}catch(l){console.error("Failed to fetch users:",l),b([])}finally{u(!1)}},j=He(W);o.useEffect(()=>{W(),j.loadLdapConfig()},[]),o.useEffect(()=>{p==="ldap"&&j.loadImportDialogData()},[p]);const ls=N.filter(l=>(l.username||"").toLowerCase().includes(x.toLowerCase())||(l.nickname||"").toLowerCase().includes(x.toLowerCase())||(l.email||"").toLowerCase().includes(x.toLowerCase())),as=l=>l==="active"?s.jsxs(os,{"code-path":"src/components/system/SystemManager.tsx:110:7",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(Js,{"code-path":"src/components/system/SystemManager.tsx:111:9",className:"h-3 w-3 mr-1"}),"正常"]}):s.jsxs(os,{"code-path":"src/components/system/SystemManager.tsx:115:7",variant:"outline",className:"border-slate-500/30 text-slate-400 bg-slate-500/10",children:[s.jsx(Gs,{"code-path":"src/components/system/SystemManager.tsx:116:9",className:"h-3 w-3 mr-1"}),"禁用"]}),rs=()=>{A(null),_({...me}),k(!0)},ds=l=>{A(l),_({username:l.username||"",nickname:l.nickname||"",email:l.email||"",phone:l.phone||"",role:Array.isArray(l.roles)?l.roles[0]||"":l.role||"",password:"",status:l.status==="active"?1:0}),k(!0)},V=async()=>{E(!0);try{const l={username:C.username,nickname:C.nickname,email:C.email,phone:C.phone,role:C.role,status:C.status};C.password&&(l.password=C.password),f?await q.updateUser(f.id,l):await q.createUser(l),k(!1),await W()}catch(l){console.error("Failed to save user:",l)}finally{E(!1)}},v=async l=>{if(await e({title:"删除用户",description:`确认删除用户「${l.nickname||l.username}」吗?`,confirmText:"删除",variant:"destructive"}))try{await q.deleteUser(l.id),await W()}catch(cs){console.error("Failed to delete user:",cs)}},H=l=>{const P=l.target.files?.[0];if(!P)return;const cs=new FileReader;cs.onload=Ts=>{const c=(Ts.target?.result).split(`
|
||
`).filter(h=>h.trim()&&!h.startsWith(""));if(c.length<2)return;const K=c[0].split(",").map(h=>h.trim().toLowerCase()),is=K.findIndex(h=>h.includes("用户名")||h.includes("username")),Rs=K.findIndex(h=>h.includes("昵称")||h.includes("name")||h.includes("显示名")),Fs=K.findIndex(h=>h.includes("邮箱")||h.includes("email")||h.includes("mail")),Ls=K.findIndex(h=>h.includes("手机")||h.includes("phone")),_s=K.findIndex(h=>h.includes("角色")||h.includes("role")),ys=K.findIndex(h=>h.includes("密码")||h.includes("password")),gs=[];for(let h=1;h<c.length;h++){const ns=c[h].split(",").map(Os=>Os.trim());gs.push({username:is>=0?ns[is]:"",nickname:Rs>=0?ns[Rs]:"",email:Fs>=0?ns[Fs]:"",phone:Ls>=0?ns[Ls]:"",role:_s>=0?ns[_s]:"",password:ys>=0?ns[ys]:""})}$(gs),ts(null)},cs.readAsText(P,"UTF-8")},ps=async()=>{j.setImporting(!0);try{const l=await q.batchImport({users:g,skip_existing:!0});ts(l),await W()}catch(l){ts({code:500,message:l?.message||"导入失败"})}finally{j.setImporting(!1)}};return s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:232:5",className:"space-y-6",children:[s.jsx("div",{"code-path":"src/components/system/SystemManager.tsx:234:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:235:9",children:[s.jsx("h1",{"code-path":"src/components/system/SystemManager.tsx:236:11",className:"text-2xl font-bold text-slate-100",children:"系统管理"}),s.jsx("p",{"code-path":"src/components/system/SystemManager.tsx:237:11",className:"text-sm text-slate-500 mt-1",children:"用户、权限与系统配置"})]})}),s.jsxs(De,{"code-path":"src/components/system/SystemManager.tsx:242:7",value:n,onValueChange:d,className:"w-full",children:[s.jsxs(fe,{"code-path":"src/components/system/SystemManager.tsx:243:9",className:"bg-slate-800 border border-slate-700",children:[s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:244:11",value:"users",className:"data-[state=active]:bg-slate-700",children:[s.jsx(de,{"code-path":"src/components/system/SystemManager.tsx:245:13",className:"h-4 w-4 mr-2"}),"用户管理"]}),s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:248:11",value:"roles",className:"data-[state=active]:bg-slate-700",children:[s.jsx(Us,{"code-path":"src/components/system/SystemManager.tsx:249:13",className:"h-4 w-4 mr-2"}),"角色权限"]}),s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:252:11",value:"settings",className:"data-[state=active]:bg-slate-700",children:[s.jsx(pe,{"code-path":"src/components/system/SystemManager.tsx:253:13",className:"h-4 w-4 mr-2"}),"系统设置"]})]}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:258:9",value:"users",className:"mt-4 space-y-4",children:s.jsx(Ae,{"code-path":"src/components/system/SystemManager.tsx:259:11",searchQuery:x,setSearchQuery:D,filteredUsers:ls,loading:a,selectedUser:I,setSelectedUser:L,getUserStatusBadge:as,dialogOpen:y,setDialogOpen:k,editingUser:f,form:C,setForm:_,saving:F,handleSubmit:V,openCreate:rs,openEdit:ds,handleDelete:v,importDialogOpen:p,setImportDialogOpen:O,importPreview:g,setImportPreview:$,importing:j.importing,importResult:es,setImportResult:ts,handleCsvUpload:H,handleBatchImport:ps,ldapUsers:j.ldapUsers,ldapSelected:j.ldapSelected,setLdapSelected:j.setLdapSelected,ldapLoading:j.ldapLoading,ldapImportOUs:j.ldapImportOUs,ldapImportOUDN:j.ldapImportOUDN,setLdapImportOUDN:j.setLdapImportOUDN,loadLdapUsers:j.loadLdapUsers,handleLdapImport:j.handleLdapImport,setLdapUsers:j.setLdapUsers})}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:299:9",value:"roles",className:"mt-4 space-y-4",children:s.jsx(Ee,{"code-path":"src/components/system/SystemManager.tsx:300:11",selectedRole:w,setSelectedRole:R})}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:306:9",value:"settings",className:"mt-4",children:s.jsx(Ve,{"code-path":"src/components/system/SystemManager.tsx:307:11",...j.settingsTabProps})})]})]})}export{gt as SystemManager};
|