Files
yakpanel-core/YakPanel/static/vite/js/file-upload-CbaM_-6s.js

2 lines
7.9 KiB
JavaScript
Raw Normal View History

2026-04-07 02:04:22 +05:30
import{k as J,R as Q,c as P,r as S,a0 as o,j as T,$ as z,Z as F,_ as $,a9 as v,aa as N,S as f,X as H,a8 as Y,aj as ee,ak as te}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{C as B,l as K,m as U,p as ae,c as se}from"./index-BTglIPU2.js?v=1773287522785";import{u as ne}from"./useTableColumns-DDeyYvje.js?v=1773287522785";import{u as oe,a as D}from"./index-C-H96YRC.js?v=1773287522785";import{u as le,ab as ie,B as re,ar as pe,a$ as ce,at as L,n as de}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-S15tYq5l.js?v=1773287522785";import"./copy-D-wIKr0q.js?v=1773287522785";import"./index-DIKmrNCq.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-DeTfbeeM.js?v=1773287522785";import"./index-Cg6fMjw6.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-C5hb-Th7.js?v=1773287522785";import"./data-BVsViUMm.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-BeO8Hyma.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-D2Bk83Ev.js?v=1773287522785";import"./useTableData-BmkIKQ_R.js?v=1773287522785";import"./FileIcon-eIHDRaxH.js?v=1773287522785";import"./soft-Cjyfamvm.js?v=1773287522785";import"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import"./useSocket-DTHwGZgK.js?v=1773287522785";import"./file-CN4ZrtIc.js?v=1773287522785";const ue={class:"p-16px"},fe={class:"flex items-center mb-12px"},me={key:1,class:"flex-center flex-col h-300px"},_e={class:"drag-text"},he={key:0,class:"drag-suffix"},ge=50*1024*1024,xe=J({__name:"file-upload",props:{path:{default:""},node_id:{},size:{},uploadData:{default:()=>({multiple:!0})},uploadSuccess:{},showSuccessMsg:{type:Boolean,default:!0}},emits:["setConfirm"],setup(R,{expose:V,emit:X}){const m=R,E=X,{path:A,node_id:M}=m,{t:l}=Q(),Z=le(),C=P(()=>({multiple:!0,...m.uploadData})),_=S([]),k=S(new Map),j=P(()=>(C.value.accept||"").split(",").map(a=>"'".concat(a,"'")).join(", ")),I=e=>{var c,u,h;const{file:a}=e;return((u=(c=a.file)==null?void 0:c.size)!=null?u:0)>1024*1024*((h=m.size)!=null?h:1/0)?(U.error(l("Component.UploadFile.index_7",[a.name,m.size])),!1):(C.value.multiple||(_.value=[]),!0)},O=e=>{const a=e.id||e.name,c=k.value.get(a);c&&(c.abort(),k.value.delete(a),e.status="error",e.percentage=0,U.info("Upload Canceled: ".concat(e.name)))},W=S([{key:"name",title:l("Component.UploadFile.index_3"),ellipsis:!0},{key:"size",title:l("Component.UploadFile.index_4"),width:100,render:e=>{var a;return B((a=e.file)==null?void 0:a.size)}},{key:"status",title:l("Component.UploadFile.index_5"),width:140,render:e=>{if(e.status==="pending")return l("Component.UploadFile.index_8");if(e.status==="finished")return o("span",{class:"text-primary"},[l("Component.UploadFile.index_9")]);if(e.status==="error")return o("span",{class:"text-error"},[T("Upload Failed")]);const a=e.percentage?e.percentage.toFixed(1):0;return o(ie,{type:"line",color:Z.value.primaryColor,"indicator-placement":"outside",processing:!0,percentage:Number(a)},null)}},ne({width:70,options:(e,a)=>[{label:l("Public.Btn.Del"),type:"error",show:e.status!=="uploading",onClick:()=>_.value.splice(a,1)},{label:l("Public.Btn.Cancel"),type:"warning",show:e.status==="uploading",onClick:()=>O(e)}]})]),q=async(e,a,c,u)=>{const g=Math.ceil(e.size/10485760);let d=0;for(let w=0;w<g;w++){if(u.signal.aborted)throw new Error("Upload Canceled");const b=d,t=Math.min(e.size,b+10485760),i=e.slice(b,t),r=t-b,n=new FormData;n.append("f_path",A),n.append("f_name",a),n.append("f_size",e.size.toString()),n.append("f_start",b.toString()),n.append("blob",i),n.append("node_id",M);try{const s=await D(n,y=>{if(u.signal.aborted)return;const x=(d+(y.progress||0)*r)/e.size*100;c(Math.min(x,99))});let p=t;if(s&&typeof s.message=="number"&&(p=s.message),d=Math.max(d,p),c(Math.min(d/e.size*100,99)),d>=e.size)break;w=Math.floor(d/10485760)-1}catch(s){let p=!1;for(let y=0;y<3;y++){if(u.signal.aborted)throw new Error("Upload Canceled");try{await new Promise(G=>setTimeout(G,1e3));const x=await D(n);if(x&&typeof x.message=="number"){