import{d as H,v as J,r as m,g as s,J as K,z as k,k as g,w as o,c as M,H as I,K as $,e as l,b as d,l as q,m as A,x as u,t as v,E as z,_ as F}from"./index-CUnFTKV2.js";import{c as G}from"./user-EiTTpYhZ.js";const Q={key:0,class:"user-info"},R={class:"user-detail"},W={class:"nickname"},X={class:"uid"},Y={class:"login-stats"},Z={class:"ip-info"},ee={class:"ip-address"},te=H({__name:"IpLogDialog",props:{modelValue:{type:Boolean},user:{}},emits:["update:modelValue"],setup(r,{emit:V}){const f=r,D=V,h=J({get:()=>f.modelValue,set:a=>D("update:modelValue",a)}),b=m(!1),C=m([]),_=m(0),n=m(1),p=m(20),y=async()=>{var a,e;if(f.user){b.value=!0;try{const i=await G(f.user.id,n.value,p.value);C.value=((a=i.data)==null?void 0:a.list)||[],_.value=((e=i.data)==null?void 0:e.total)||0}catch(i){console.error("获取IP登录历史失败",i),C.value=[],_.value=0}finally{b.value=!1}}},P=a=>{n.value=a,y()},L=a=>{p.value=a,n.value=1,y()},B=async a=>{try{await navigator.clipboard.writeText(a),z.success("IP地址已复制")}catch{const e=document.createElement("textarea");e.value=a,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),z.success("IP地址已复制")}},S=()=>{n.value=1,p.value=20,y()},x=()=>{h.value=!1};return(a,e)=>{const i=s("el-icon"),U=s("el-avatar"),E=s("el-statistic"),c=s("el-table-column"),w=s("el-button"),N=s("el-table"),T=s("el-pagination"),O=s("el-dialog"),j=K("loading");return g(),k(O,{modelValue:h.value,"onUpdate:modelValue":e[2]||(e[2]=t=>h.value=t),title:"IP登录历史",width:"800px","close-on-click-modal":!1,onClose:x,onOpen:S},{footer:o(()=>[l(w,{onClick:x},{default:o(()=>[...e[4]||(e[4]=[v("关闭",-1)])]),_:1})]),default:o(()=>[r.user?(g(),M("div",Q,[l(U,{src:r.user.avatar,size:40},{default:o(()=>[l(i,null,{default:o(()=>[l(q(A))]),_:1})]),_:1},8,["src"]),d("div",R,[d("div",W,u(r.user.nickname||"-"),1),d("div",X,"UID: "+u(r.user.id),1)]),d("div",Y,[l(E,{title:"登录记录数",value:_.value},null,8,["value"])])])):I("",!0),$((g(),k(N,{data:C.value,border:"",stripe:"","max-height":"400"},{default:o(()=>[l(c,{prop:"id",label:"ID",width:"80"}),l(c,{prop:"loginDate",label:"登录日期",width:"120"}),l(c,{label:"登录时间",width:"170"},{default:o(({row:t})=>[v(u(t.loginTime||t.lastLoginTime||"-"),1)]),_:1}),l(c,{prop:"ip",label:"IP地址","min-width":"150"},{default:o(({row:t})=>[d("div",Z,[d("span",ee,u(t.ip||"-"),1),t.ip?(g(),k(w,{key:0,type:"primary",link:"",size:"small",onClick:ae=>B(t.ip)},{default:o(()=>[...e[3]||(e[3]=[v(" 复制 ",-1)])]),_:1},8,["onClick"])):I("",!0)])]),_:1}),l(c,{prop:"location",label:"归属地","min-width":"150"},{default:o(({row:t})=>[v(u(t.location||"-"),1)]),_:1}),l(c,{prop:"device",label:"设备信息","min-width":"150","show-overflow-tooltip":""},{default:o(({row:t})=>[v(u(t.device||"-"),1)]),_:1})]),_:1},8,["data"])),[[j,b.value]]),l(T,{"current-page":n.value,"onUpdate:currentPage":e[0]||(e[0]=t=>n.value=t),"page-size":p.value,"onUpdate:pageSize":e[1]||(e[1]=t=>p.value=t),"page-sizes":[10,20,50,100],total:_.value,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:L,onCurrentChange:P,class:"pagination"},null,8,["current-page","page-size","total"])]),_:1},8,["modelValue"])}}}),se=F(te,[["__scopeId","data-v-85f89221"]]);export{se as default};
