import{c as V,B as T,u as q,r as _,b as k,d as c,e as t,n as o,g as a,i as A,j as P,f as m,v as H,m as I,F as v,q as w,t as d,A as S,z as g}from"./index-Dm7yhqOC.js";import{F as L}from"./file-rOVCfWLN.js";/** * @license lucide-vue-next v0.445.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M=V("SearchIcon",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),E={class:"p-6 h-screen overflow-y-auto custom-scrollbar"},U={class:"mb-6 flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between"},Y={class:"flex flex-1 gap-4"},G={class:"relative flex-1"},J={class:"flex gap-4"},K={class:"overflow-x-auto"},O={class:"px-6 py-4 whitespace-nowrap"},Q={class:"flex items-center"},R={class:"px-6 py-4 whitespace-nowrap"},W={class:"flex items-center"},X={class:"px-6 py-4 whitespace-nowrap"},Z={class:"px-6 py-4 whitespace-nowrap"},N={class:"px-6 py-4 whitespace-nowrap"},tt={class:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium"},et=["onClick"],at={class:"flex items-center space-x-2"},st=["disabled"],rt={class:"flex items-center space-x-1"},ot=["onClick"],lt=["disabled"],ct=T({__name:"FileManageView",setup(nt){const C=q();function $(n){const l=new Date(n),e=l.getFullYear(),i=(l.getMonth()+1).toString().padStart(2,"0"),x=l.getDate().toString().padStart(2,"0"),h=l.getHours().toString().padStart(2,"0"),y=l.getMinutes().toString().padStart(2,"0"),B=l.getSeconds().toString().padStart(2,"0");return`${e}-${i}-${x} ${h}:${y}:${B}`}const r=A("isDarkMode"),f=_([]),F=["取件码","名称","大小","描述","过期时间","操作"],s=_({page:1,size:10,total:0,keyword:""}),z=async n=>{try{await S({url:"/admin/file/delete",method:"delete",data:{id:n}}),await p()}catch(l){console.error("删除失败:",l)}},p=async()=>{try{const n=await S({url:"/admin/file/list",method:"get",params:s.value});f.value=n.detail.data,s.value.total=n.detail.total,C.showAlert("加载成功","success")}catch(n){console.error("加载文件列表失败:",n)}},b=async n=>{n<1||n>u.value||(s.value.page=n,await p())};p();const u=k(()=>Math.ceil(s.value.total/s.value.size)),D=k(()=>{const n=s.value.page,l=u.value,e=2;let i=[];i.push(1);let x=Math.max(2,n-e),h=Math.min(l-1,n+e);x>2&&i.push("...");for(let y=x;y<=h;y++)i.push(y);return h1&&i.push(l),i}),j=async()=>{s.value.page=1,await p()};return(n,l)=>(g(),c("div",E,[t("h2",{class:o(["text-2xl font-bold mb-6",[a(r)?"text-white":"text-gray-800"]])}," 文件管理 ",2),t("div",U,[t("div",Y,[t("div",G,[P(t("input",{type:"text","onUpdate:modelValue":l[0]||(l[0]=e=>s.value.keyword=e),class:o([[a(r)?"bg-gray-700 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400"],"w-full pl-10 pr-4 py-2 rounded-lg border focus:ring-2 focus:ring-indigo-500 focus:border-transparent"]),placeholder:"搜索文件..."},null,2),[[H,s.value.keyword]]),m(a(M),{class:o(["absolute left-3 top-2.5 w-5 h-5",[a(r)?"text-gray-400":"text-gray-500"]])},null,8,["class"])])]),t("div",J,[t("button",{onClick:j,class:"flex items-center px-4 py-2 rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 transition-colors duration-200"},[m(a(M),{class:"w-5 h-5 mr-2"}),l[3]||(l[3]=I(" 搜索 "))])])]),t("div",{class:o(["rounded-lg shadow-md overflow-hidden transition-colors duration-300",[a(r)?"bg-gray-800 bg-opacity-70":"bg-white"]])},[t("div",{class:o(["px-6 py-4 border-b",[a(r)?"border-gray-700":"border-gray-200"]])},[t("h3",{class:o(["text-lg font-medium",[a(r)?"text-white":"text-gray-800"]])}," 所有文件 ",2)],2),t("div",K,[t("table",{class:o(["min-w-full divide-y",[a(r)?"divide-gray-700":"divide-gray-200"]])},[t("thead",{class:o([a(r)?"bg-gray-900":"bg-gray-100"])},[t("tr",null,[(g(),c(v,null,w(F,e=>t("th",{key:e,class:o(["px-6 py-3 text-left text-xs font-medium uppercase tracking-wider",[a(r)?"text-gray-400":"text-gray-500"]])},d(e),3)),64))])],2),t("tbody",{class:o([a(r)?"bg-gray-800 divide-y divide-gray-700":"bg-white divide-y divide-gray-200"])},[(g(!0),c(v,null,w(f.value,e=>(g(),c("tr",{key:e.id},[t("td",O,[t("div",Q,[t("span",{class:o(["font-medium",[a(r)?"text-white":"text-gray-900"]])},d(e.code),3)])]),t("td",R,[t("div",W,[m(a(L),{class:o(["w-5 h-5 mr-2",[a(r)?"text-indigo-400":"text-indigo-500"]])},null,8,["class"]),t("span",{class:o(["font-medium",[a(r)?"text-white":"text-gray-900"]])},d(e.prefix),3)])]),t("td",X,[t("span",{class:o([a(r)?"text-gray-400":"text-gray-500"])},d(Math.round(e.size/1024/1024*100)/100)+"MB ",3)]),t("td",Z,[t("span",{class:o([a(r)?"text-gray-400":"text-gray-500"])},d(e.text),3)]),t("td",N,[t("span",{class:o([a(r)?"text-gray-400":"text-gray-500"])},d(e.expired_at?$(e.expired_at):"永久"),3)]),t("td",tt,[t("button",{onClick:i=>z(e.id),class:o(["transition-colors duration-200",[a(r)?"text-red-400 hover:text-red-300":"text-red-600 hover:text-red-900"]])}," 删除 ",10,et)])]))),128))],2)],2)])],2),t("div",{class:o(["mt-4 flex items-center justify-between px-6 py-3 border-t",[a(r)?"border-gray-700":"border-gray-200"]])},[t("div",{class:o(["flex items-center text-sm",[a(r)?"text-gray-400":"text-gray-500"]])}," 显示第 "+d((s.value.page-1)*s.value.size+1)+" 到 "+d(Math.min(s.value.page*s.value.size,s.value.total))+" 条,共 "+d(s.value.total)+" 条 ",3),t("div",at,[t("button",{onClick:l[1]||(l[1]=e=>b(s.value.page-1)),disabled:s.value.page===1,class:o(["px-3 py-1 rounded-md transition-colors duration-200",[a(r)?s.value.page===1?"bg-gray-700 text-gray-500 cursor-not-allowed":"bg-gray-700 text-gray-300 hover:bg-gray-600":s.value.page===1?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])}," 上一页 ",10,st),t("div",rt,[(g(!0),c(v,null,w(D.value,e=>(g(),c(v,{key:e},[e!=="..."?(g(),c("button",{key:0,onClick:i=>b(e),class:o(["px-3 py-1 rounded-md transition-colors duration-200",[s.value.page===e?"bg-indigo-600 text-white":a(r)?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])},d(e),11,ot)):(g(),c("span",{key:1,class:o(["px-2",[a(r)?"text-gray-400":"text-gray-500"]])}," ... ",2))],64))),128))]),t("button",{onClick:l[2]||(l[2]=e=>b(s.value.page+1)),disabled:s.value.page>=u.value,class:o(["px-3 py-1 rounded-md transition-colors duration-200",[a(r)?s.value.page>=u.value?"bg-gray-700 text-gray-500 cursor-not-allowed":"bg-gray-700 text-gray-300 hover:bg-gray-600":s.value.page>=u.value?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])}," 下一页 ",10,lt)])],2)]))}});export{ct as default};