Files
senmesh-zc/deployment/iw/web/assets/my-C6gzFuIT.js

3 lines
15 KiB
JavaScript
Raw Normal View History

import{t as e}from"./useQuery-dxbdhNvu.js";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./select-stsOu5jD.js";import{n as s,t as c}from"./file-category-filter-BIAErrxo.js";import{t as l}from"./file-COj1kCUn.js";import{t as u}from"./folder-input--tEWrMtP.js";import{t as d}from"./folder-Dl7FxCLT.js";import{n as f,t as p}from"./remove-file-dialog-cN0TGs4y.js";import{t as m}from"./shield-alert-XSqo2W3w.js";import{t as h}from"./upload-Cr-BixPb.js";import{$ as g,F as _,Ft as v,G as y,H as b,J as x,Nt as S,Pt as C,Q as w,Qt as T,U as E,V as ee,Vn as D,W as O,Z as k,Zt as A,_n as te,ct as j,dt as M,et as N,fn as P,ft as F,ln as I,lt as ne,n as L,pt as R,q as z,qn as B,st as re,tn as V,tt as H,ut as U,wt as ie,yn as W,zn as ae}from"./index-BaTxSAlR.js";import{t as oe}from"./directory-breadcrumb-u3uCxukv.js";import{t as se}from"./data-table-CEq6a930.js";import{t as ce}from"./pagination-Bragnnjj.js";import{t as le}from"./use-fetch-files-rnWwNE4C.js";import{a as G,n as K,o as q,r as J,s as Y,t as X}from"./dialog-CnxDxMp1.js";import{n as ue,t as de}from"./es-6YDPW35u.js";import{i as fe,n as pe,r as me,t as he}from"./use-upload-config-OxxQwpLm.js";import{t as ge}from"./use-security-enabled-CyVC7otU.js";var _e=P(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),ve=P(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Z=B(D(),1);const ye=e=>{let{mutateAsync:t,isPending:n}=W({mutationFn:e=>e.id?ie(e):M(e),...e||{}});return{save:e=>{I.promise(t(e),{loading:`提交中...`,success:`操作成功`})},saveIsPending:n}};var Q=B(ae(),1),be=w({fileName:g().min(1,{message:`目录至少1个字符`}).max(32,{message:`目录最多32个字符`}).nonempty({message:`目录不能为空`})});function xe({open:e,setOpen:t,data:n,parentId:r,refetch:i}){let a=H({resolver:N(be),defaultValues:{fileName:``}}),{save:o,saveIsPending:s}=ye({onSuccess:()=>{i==null||i(),t(!1)}}),c=e=>{o({...n||{},...e,parentId:r})};return(0,Z.useEffect)(()=>{e&&a.reset({fileName:(n==null?void 0:n.fileName)||``})},[e,n]),(0,Q.jsx)(X,{open:e,onOpenChange:t,children:(0,Q.jsxs)(J,{className:`w-[400px]`,children:[(0,Q.jsx)(q,{children:(0,Q.jsx)(Y,{children:(n==null?void 0:n.fileType)===j.DIRECTORY&&!(n!=null&&n.id)?`创建目录`:`重命名`})}),(0,Q.jsx)(b,{...a,children:(0,Q.jsxs)(`form`,{onSubmit:a.handleSubmit(c),className:`space-y-4`,children:[(0,Q.jsx)(O,{control:a.control,name:`fileName`,render:({field:e})=>(0,Q.jsxs)(y,{children:[(0,Q.jsx)(E,{children:(0,Q.jsx)(ee,{placeholder:(n==null?void 0:n.fileType)===j.DIRECTORY?`请输入目录名`:`请输入文件名`,...e})}),(0,Q.jsx)(z,{})]})}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(T,{variant:`outline`,children:`取消`})}),(0,Q.jsxs)(T,{type:`submit`,disabled:s,children:[s&&(0,Q.jsx)(A,{}),`确定`]})]})]})})]})})}var Se=`.docx,.txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.csv,.pptx,.xml,.epub,.mp3,.m4a,.wav,.amr,.mpga,.mp4,.mov,.mpeg,.webm,.jpg,.jpeg,.png,.gif,.svg`,Ce=50;function we({open:e,setOpen:t,parentId:n,refetch:r}){let{data:i}=me(),a=!!i&&i.uploadEnabled===!1,o=i!=null&&i.allowAllType?null:(i==null?void 0:i.allowedSuffixes)||null,s=he(i)??Se,c=i!=null&&i.maxFileSize&&i.maxFileSize>0?i.maxFileSize:Ce,l=pe(i)??Ce*1024*1024,{mutateAsync:u,isPending:d}=W({mutationFn:e=>v(e).then(e=>{var t,r;return M({fileCode:(t=e.data)==null?void 0:t.fileCode,fileName:(r=e.data)==null?void 0:r.fileName,fileType:j.FILE,parentId:n})})}),{getRootProps:f,getInputProps:p,isDragActive:m}=de({onDropAccepted:(0,Z.useCallback)(e=>{Promise.allSettled(e.map(async e=>{try{i!=null&&i.configured&&await fe({fileName:e.name,fileSize:e.size})}catch{return null}return u(e)})).then(e=>{e.filter(e=>e.status===`fulfille
${a?`border-muted-foreground/25 opacity-60`:`cursor-pointer hover:border-primary`}
${m?`border-primary bg-primary/5`:`border-muted-foreground/25`}`,children:[d&&(0,Q.jsx)(`div`,{className:`absolute left-0 right-0 top-0 bottom-0 flex items-center justify-center backdrop-blur-xs bg-white/80 z-50`,children:(0,Q.jsx)(A,{className:`h-12 w-12 text-primary`})}),(0,Q.jsxs)(`div`,{...f(),className:`p-8 rounded-lg outline-none`,children:[(0,Q.jsx)(`input`,{...p({accept:s})}),(0,Q.jsx)(`div`,{className:`p-4 rounded-full bg-gray-50 inline-flex justify-center items-center`,children:(0,Q.jsx)(h,{className:`mx-auto h-6 w-6 text-muted-foreground`})}),(0,Q.jsx)(`p`,{className:`mt-2 text-lg`,children:a?`当前机构已禁止上传文件`:m?`松开鼠标以选择文件`:`拖放文件到这里,或点击选择`}),a?(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-black/50`,children:`请联系机构管理员开启上传权限`}):(0,Q.jsxs)(`p`,{className:`mt-2 text-sm text-black/50`,children:[o!=null&&o.length?`仅允许上传后缀为 ${o.join(`、`)} 的文件,`:``,`文件最大不能超过`,c,`MB`]})]})]})]})})}const Te=e=>{let{mutateAsync:t,isPending:n}=W({mutationFn:F,...e||{}});return{share:e=>{I.promise(t(e),{loading:`提交中...`,success:`操作成功`})},shareIsPending:n}};function Ee({check:e,actionName:t}){let n=(e==null?void 0:e.blockedFileNames)||[],r=(e==null?void 0:e.scanningFileNames)||[];return!n.length&&!r.length?null:(0,Q.jsxs)(`div`,{className:`rounded-md border border-red-200 bg-red-500/5 p-2.5 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-500 leading-relaxed`,children:[(0,Q.jsx)(m,{size:14,className:`flex-none mt-0.5`}),(0,Q.jsxs)(`span`,{children:[`该目录下有 `,n.length,` 个文件安全检测未通过`,r.length>0&&`、${r.length} 个正在检测中`,`,确认后仅`,t,`检测通过的文件`]})]}),(0,Q.jsxs)(`div`,{className:`max-h-24 overflow-auto space-y-0.5 pl-5`,children:[n.map(e=>(0,Q.jsxs)(`div`,{className:`text-xs text-red-400 break-all`,children:[`• `,e]},e)),r.map(e=>(0,Q.jsxs)(`div`,{className:`text-xs text-amber-500 break-all`,children:[`• `,e,`(检测中)`]},e))]})]})}var De=w({validDays:k().or(g())});function Oe({open:s,setOpen:c,data:u}){var f;let p=H({resolver:N(De),defaultValues:{validDays:1}}),m=(u==null?void 0:u.fileType)===j.DIRECTORY,{data:h}=e({queryKey:[`shareSecurityCheck`,u==null?void 0:u.id,s],queryFn:()=>S(u.id).then(e=>e.data),enabled:s&&m}),g=(h==null||(f=h.excludeFileIds)==null?void 0:f.length)||0,{share:_,shareIsPending:v}=Te({onSuccess:()=>{c(!1)}}),C=e=>{_({userFileId:u.id,validDays:e.validDays,onlyPassed:g>0})};return(0,Z.useEffect)(()=>{s&&p.reset()},[s,u]),(0,Q.jsx)(X,{open:s,onOpenChange:c,children:(0,Q.jsxs)(J,{className:`w-[400px]`,children:[(0,Q.jsx)(q,{children:(0,Q.jsx)(Y,{children:`分享文件`})}),(0,Q.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-sm p-2 rounded-md bg-gray-50`,children:[(u==null?void 0:u.fileType)===j.FILE?(0,Q.jsx)(l,{size:16,className:`text-primary flex-none`}):(0,Q.jsx)(d,{size:16,className:`text-amber-500 flex-none`}),(0,Q.jsx)(`span`,{className:`break-all`,children:u==null?void 0:u.fileName})]}),m&&g>0&&(0,Q.jsx)(Ee,{check:h,actionName:`分享`}),(0,Q.jsx)(b,{...p,children:(0,Q.jsxs)(`form`,{onSubmit:p.handleSubmit(C),className:`space-y-4`,children:[(0,Q.jsx)(O,{control:p.control,name:`validDays`,render:({field:e})=>(0,Q.jsxs)(y,{children:[(0,Q.jsx)(x,{children:`有效期`}),(0,Q.jsx)(E,{children:(0,Q.jsxs)(o,{onValueChange:e.onChange,value:e.value.toString(),children:[(0,Q.jsx)(t,{className:`w-full`,children:(0,Q.jsx)(i,{placeholder:`请选择有效期`})}),(0,Q.jsx)(r,{children:(0,Q.jsxs)(a,{children:[(0,Q.jsx)(n,{value:`1`,children:`1天`}),(0,Q.jsx)(n,{value:`3`,children:`3天`}),(0,Q.jsx)(n,{value:`5`,children:`5天`}),(0,Q.jsx)(n,{value:`7`,children:`7天`}),(0,Q.jsx)(n,{value:`15`,children:`15天`})]})})]})}),(0,Q.jsx)(z,{})]})}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(T,{variant:`outline`,children:`取消`})}),(0,Q.jsxs)(T,{type:`submit`,disabled:v,children:[v&&(0,Q.jsx)(A,{}),`确定`]})]})]})})]})})}const ke=e=>{l