import"./rolldown-runtime-BM3Ffeng.js";import{a as e,at as t,d as n,f as r,k as ee,n as i,ot as a}from"./element-plus-vendor-BF9PNysW.js";import{A as o,Ct as s,D as c,E as l,I as u,N as d,O as f,P as p,Pt as m,Tt as h,Xt as g,et as _,gt as v,ht as y,k as b,pt as x}from"./vue-vendor-DMUmTARL.js";import{Na as S}from"./icons-vendor-Db5MGAkr.js";import{S as C,l as w,n as T,v as E}from"./index-kSn5YXd0.js";import{t as D}from"./pro-capability-BR-p0W7Z.js";import{t as O}from"./useCapability-DVpkmSeo.js";import{t as k}from"./AdminSettingLayout-CzCwKa9p.js";import{t as A}from"./admin-form-header-DFAG_myc.js";import{t as j}from"./route-block-D7Rwj2No.js";import{t as te}from"./AdminPagination-8XDk0p1I.js";import{t as M}from"./ProGuard-B3_o-Ekd.js";var N=(e,t)=>T({url:`/api/admin/session/online`,method:`get`,data:{page:e,limit:t},config:{showDefaultMsg:!1}}),P=e=>T({url:`/api/admin/session/kickout`,method:`post`,data:{tokenValue:e}}),F={class:`zf-admin-online-session flex h-full flex-col`},I={class:`mb-4 flex items-center justify-between`},L={class:`text-sm text-secondary`},R={class:`font-medium text-primary`},z={class:`flex items-center gap-2`},B={class:`font-medium`},V={class:`font-mono`},H={key:1},U={class:`font-mono tabular-nums`},W={class:`font-mono tabular-nums`},G={class:`font-mono text-secondary`},K=u({__name:`index`,setup(u){let T=w(),j=E(),{isCapabilityEnabled:K}=O(),q=l(()=>K(D.onlineSession)),J=s({page:1,limit:10}),Y=h([]),X=h(0),Z=h(!1),Q=h(null),ne=e=>e?C(new Date(e)):`-`,re=e=>e?C(new Date(e)):`永不过期`,ie={password:`密码`,passkey:`Passkey`,sso:`单点登录`},ae=e=>e?ie[e]??e:`-`,$=()=>{q.value&&(Z.value=!0,N(J.page,J.limit).then(e=>{let t=e.data??{totalCount:0,records:[]};Y.value=t.records??[],X.value=t.totalCount??0}).finally(()=>{Z.value=!1}))},oe=async e=>{let t=e.username||e.loginId||`该终端`;try{await i.confirm(`确认强制下线「${t}」（IP：${e.ip||`未知`}）的会话？该终端将立即失效需重新登录。`,`踢下线`,{type:`warning`,confirmButtonText:`踢下线`,cancelButtonText:`取消`})}catch{return}Q.value=e.tokenValue;try{await P(e.tokenValue),j.success(`已强制下线`),Y.value.length===1&&J.page>1&&--J.page,$()}catch(e){console.error(`踢下线失败:`,e)}finally{Q.value=null}};return x(q,e=>{e&&$()},{immediate:!0}),(i,s)=>{let l=A,u=a,h=t,x=r,C=ee,w=n,E=te,O=k,j=e;return _(),o(`div`,F,[p(O,null,{default:y(()=>[p(l,{pro:``,"hide-bottom-border":``,title:`在线会话`,"sub-title":`在这里你可以查看当前所有在线终端（登录会话），并对可疑会话执行强制下线。`}),p(M,{capability:m(D).onlineSession},{default:y(()=>[c(`div`,I,[c(`span`,L,[s[2]||=d(` 当前在线终端：`,-1),c(`span`,R,g(X.value),1),s[3]||=d(` 个 `,-1)]),p(u,{icon:m(S),loading:Z.value,onClick:$},{default:y(()=>[...s[4]||=[d(`刷新`,-1)]]),_:1},8,[`icon`,`loading`])]),v((_(),f(w,{border:``,data:Y.value,size:m(T).adminTable.size},{empty:y(()=>[p(C,{"image-size":80,description:`暂无在线会话`})]),default:y(()=>[p(x,{label:`登录账号`,"min-width":`140`},{default:y(({row:e})=>[c(`div`,z,[c(`span`,B,g(e.username||e.loginId||`-`),1),e.admin?(_(),f(h,{key:0,size:`small`,type:`warning`},{default:y(()=>[...s[5]||=[d(`管理员`,-1)]]),_:1})):b(``,!0),e.current?(_(),f(h,{key:1,size:`small`,type:`success`},{default:y(()=>[...s[6]||=[d(`当前`,-1)]]),_:1})):b(``,!0)])]),_:1}),p(x,{label:`请求 IP`,"min-width":`120`,"show-overflow-tooltip":``},{default:y(({row:e})=>[c(`span`,V,g(e.ip||`-`),1)]),_:1}),p(x,{label:`终端 / UserAgent`,"min-width":`220`,"show-overflow-tooltip":``},{default:y(({row:e})=>[d(g(e.userAgent||e.deviceType||`-`),1)]),_:1}),p(x,{label:`登录方式`,width:`110`},{default:y(({row:e})=>[e.loginType?(_(),f(h,{key:0,size:`small`,type:`info`},{default:y(()=>[d(g(ae(e.loginType)),1)]),_:2},1024)):(_(),o(`span`,H,`-`))]),_:1}),p(x,{label:`登录时间`,width:`180`},{default:y(({row:e})=>[c(`span`,U,g(ne(e.loginTime)),1)]),_:1}),p(x,{label:`过期时间`,width:`180`},{default:y(({row:e})=>[c(`span`,W,g(re(e.expireTime)),1)]),_:1}),p(x,{label:`令牌`,width:`160`,"show-overflow-tooltip":``},{default:y(({row:e})=>[c(`span`,G,g(e.maskedToken||`-`),1)]),_:1}),p(x,{label:`操作`,width:`110`,align:`center`,fixed:`right`},{default:y(({row:e})=>[p(u,{type:`danger`,link:``,disabled:e.current,title:e.current?`不能下线当前会话`:``,loading:Q.value===e.tokenValue,onClick:t=>oe(e)},{default:y(()=>[...s[7]||=[d(` 踢下线 `,-1)]]),_:1},8,[`disabled`,`title`,`loading`,`onClick`])]),_:1})]),_:1},8,[`data`,`size`])),[[j,Z.value]]),p(E,{page:J.page,"onUpdate:page":s[0]||=e=>J.page=e,limit:J.limit,"onUpdate:limit":s[1]||=e=>J.limit=e,total:X.value,onChange:$},null,8,[`page`,`limit`,`total`])]),_:1},8,[`capability`])]),_:1})])}}});typeof j==`function`&&j(K);var q=K;export{q as default};