Files
filecodebox/themes/2024/assets/FileManageView-CFwIZb1n.js
T
2025-03-03 23:07:51 +08:00

17 lines
8.4 KiB
Python

import{c as _,d as j,r as C,f as M,a as c,b as e,n as o,h as t,i as q,m as B,g as p,v as I,L as P,s as m,F as b,q as f,t as i,A as $,e as g}from"./index-CYBANwZ9.js";import{F as H}from"./file-DFHgIt1-.js";import{T as K}from"./trash-WuIkVMez.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 R=_("ChevronLeftIcon",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
* @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 A=_("ChevronRightIcon",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @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 F=_("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-8"},Y={class:"flex flex-1 gap-4 w-full sm:w-auto"},G={class:"relative flex-1"},J={class:"overflow-x-auto"},O={class:"px-6 py-4 whitespace-nowrap"},Q={class:"flex items-center"},W={class:"px-6 py-4"},X={class:"flex items-center group relative"},Z=["title"],N={class:"absolute left-0 -top-2 -translate-y-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none"},ee={class:"bg-gray-900 text-white text-sm rounded px-2 py-1 max-w-xs break-all"},te={class:"px-6 py-4 whitespace-nowrap"},ae={class:"px-6 py-4"},se={class:"group relative"},re={class:"absolute left-0 -top-2 -translate-y-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none z-10"},oe={class:"bg-gray-900 text-white text-sm rounded px-2 py-1 max-w-xs break-all"},ne={class:"px-6 py-4 whitespace-nowrap"},le={class:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium"},ie=["onClick"],de={class:"flex items-center space-x-2"},ce=["disabled"],ge={class:"flex items-center space-x-1"},pe=["onClick"],ye=["disabled"],me=j({__name:"FileManageView",setup(ue){function z(l){const s=new Date(l),a=s.getFullYear(),d=(s.getMonth()+1).toString().padStart(2,"0"),h=s.getDate().toString().padStart(2,"0"),v=s.getHours().toString().padStart(2,"0"),u=s.getMinutes().toString().padStart(2,"0"),V=s.getSeconds().toString().padStart(2,"0");return`${a}-${d}-${h} ${v}:${u}:${V}`}const r=q("isDarkMode"),k=C([]),D=["取件码","名称","大小","描述","过期时间","操作"],n=C({page:1,size:10,total:0,keyword:""}),T=async l=>{try{await $({url:"/admin/file/delete",method:"delete",data:{id:l}}),await x()}catch(s){console.error("删除失败:",s)}},x=async()=>{try{const l=await $({url:"/admin/file/list",method:"get",params:n.value});k.value=l.detail.data,n.value.total=l.detail.total}catch(l){console.error("加载文件列表失败:",l)}},w=async l=>{l<1||l>y.value||(n.value.page=l,await x())};x();const y=M(()=>Math.ceil(n.value.total/n.value.size)),L=M(()=>{const l=n.value.page,s=y.value,a=2;let d=[];d.push(1);let h=Math.max(2,l-a),v=Math.min(s-1,l+a);h>2&&d.push("...");for(let u=h;u<=v;u++)d.push(u);return v<s-1&&d.push("..."),s>1&&d.push(s),d}),S=async()=>{n.value.page=1,await x()};return(l,s)=>(g(),c("div",E,[e("div",U,[e("h2",{class:o(["text-2xl font-bold mb-4",[t(r)?"text-white":"text-gray-800"]])}," 文件管理 ",2)]),e("div",{class:o(["mb-6 flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between bg-opacity-70 p-4 rounded-lg shadow-sm",[t(r)?"bg-gray-800":"bg-white"]])},[e("div",Y,[e("div",G,[B(e("input",{type:"text","onUpdate:modelValue":s[0]||(s[0]=a=>n.value.keyword=a),onKeyup:P(S,["enter"]),class:o([t(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.5 rounded-lg border focus:ring-2 focus:ring-indigo-500 focus:border-transparent"]),placeholder:"搜索文件名称、描述..."},null,34),[[I,n.value.keyword]]),p(t(F),{class:o(["absolute left-3 top-3 w-5 h-5",[t(r)?"text-gray-400":"text-gray-500"]])},null,8,["class"])]),e("button",{onClick:S,class:"px-4 py-2.5 rounded-lg inline-flex items-center transition-all duration-200 bg-indigo-600 hover:bg-indigo-700 text-white shadow-sm"},[p(t(F),{class:"w-5 h-5 mr-2"}),s[3]||(s[3]=m(" 搜索 "))])])],2),e("div",{class:o(["rounded-lg shadow-sm overflow-hidden transition-all duration-300",[t(r)?"bg-gray-800 bg-opacity-70":"bg-white"]])},[e("div",{class:o(["px-6 py-4 border-b",[t(r)?"border-gray-700":"border-gray-200"]])},[e("h3",{class:o(["text-lg font-medium",[t(r)?"text-white":"text-gray-800"]])}," 所有文件 ",2)],2),e("div",J,[e("table",{class:o(["min-w-full divide-y",[t(r)?"divide-gray-700":"divide-gray-200"]])},[e("thead",{class:o([t(r)?"bg-gray-900/50":"bg-gray-50"])},[e("tr",null,[(g(),c(b,null,f(D,a=>e("th",{key:a,class:o(["px-6 py-3.5 text-left text-xs font-medium uppercase tracking-wider",[t(r)?"text-gray-400":"text-gray-500"]])},i(a),3)),64))])],2),e("tbody",{class:o([t(r)?"bg-gray-800/50 divide-y divide-gray-700":"bg-white divide-y divide-gray-200"])},[(g(!0),c(b,null,f(k.value,a=>(g(),c("tr",{key:a.id,class:o(["hover:bg-opacity-50 transition-colors duration-200",[t(r)?"hover:bg-gray-700":"hover:bg-gray-50"]])},[e("td",O,[e("div",Q,[e("span",{class:o(["font-medium select-all",[t(r)?"text-white":"text-gray-900"]])},i(a.code),3)])]),e("td",W,[e("div",X,[p(t(H),{class:o(["w-5 h-5 mr-2 flex-shrink-0",[t(r)?"text-indigo-400":"text-indigo-500"]])},null,8,["class"]),e("span",{class:o(["font-medium truncate max-w-[200px]",[t(r)?"text-white":"text-gray-900"]]),title:a.prefix},i(a.prefix),11,Z),e("div",N,[e("div",ee,i(a.prefix),1)])])]),e("td",te,[e("span",{class:o(["inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",[t(r)?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-800"]])},i(Math.round(a.size/1024/1024*100)/100)+"MB ",3)]),e("td",ae,[e("div",se,[e("span",{class:o(["block truncate max-w-[250px]",[t(r)?"text-gray-400":"text-gray-500"]])},i(a.text),3),e("div",re,[e("div",oe,i(a.text),1)])])]),e("td",ne,[e("span",{class:o(["inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",[a.expired_at?t(r)?"bg-yellow-900/30 text-yellow-400":"bg-yellow-100 text-yellow-800":t(r)?"bg-green-900/30 text-green-400":"bg-green-100 text-green-800"]])},i(a.expired_at?z(a.expired_at):"永久"),3)]),e("td",le,[e("button",{onClick:d=>T(a.id),class:o(["inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200",[t(r)?"bg-red-900/20 text-red-400 hover:bg-red-900/30":"bg-red-50 text-red-600 hover:bg-red-100"]])},[p(t(K),{class:"w-4 h-4 mr-1.5"}),s[4]||(s[4]=m(" 删除 "))],10,ie)])],2))),128))],2)],2)]),e("div",{class:o(["mt-4 flex items-center justify-between px-6 py-4 border-t",[t(r)?"border-gray-700":"border-gray-200"]])},[e("div",{class:o(["flex items-center text-sm",[t(r)?"text-gray-400":"text-gray-500"]])}," 显示第 "+i((n.value.page-1)*n.value.size+1)+" 到 "+i(Math.min(n.value.page*n.value.size,n.value.total))+" 条,共 "+i(n.value.total)+" 条 ",3),e("div",de,[e("button",{onClick:s[1]||(s[1]=a=>w(n.value.page-1)),disabled:n.value.page===1,class:o(["inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200",[t(r)?n.value.page===1?"bg-gray-800 text-gray-600 cursor-not-allowed":"bg-gray-800 text-gray-300 hover:bg-gray-700":n.value.page===1?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])},[p(t(R),{class:"w-4 h-4"}),s[5]||(s[5]=m(" 上一页 "))],10,ce),e("div",ge,[(g(!0),c(b,null,f(L.value,a=>(g(),c(b,{key:a},[a!=="..."?(g(),c("button",{key:0,onClick:d=>w(a),class:o(["inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200",[n.value.page===a?"bg-indigo-600 text-white":t(r)?"bg-gray-800 text-gray-300 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])},i(a),11,pe)):(g(),c("span",{key:1,class:o(["px-2",[t(r)?"text-gray-400":"text-gray-500"]])}," ... ",2))],64))),128))]),e("button",{onClick:s[2]||(s[2]=a=>w(n.value.page+1)),disabled:n.value.page>=y.value,class:o(["inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200",[t(r)?n.value.page>=y.value?"bg-gray-800 text-gray-600 cursor-not-allowed":"bg-gray-800 text-gray-300 hover:bg-gray-700":n.value.page>=y.value?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"]])},[s[6]||(s[6]=m(" 下一页 ")),p(t(A),{class:"w-4 h-4"})],10,ye)])],2)],2)]))}});export{me as default};