var d=(o,a,n)=>new Promise((i,r)=>{var c=e=>{try{t(n.next(e))}catch(s){r(s)}},l=e=>{try{t(n.throw(e))}catch(s){r(s)}},t=e=>e.done?i(e.value):Promise.resolve(e.value).then(c,l);t((n=n.apply(o,a)).next())});import{d as b,G as v,M as _,o as f,c as p,e as m,S as u,b as w,t as N,i as g,U as y,T as k}from"./index-90c78f99.js";import{_ as x}from"./index.vue_vue_type_style_index_0_lang-3eaf88fd.js";import{u as L}from"./useCurrentInstance-cd4729ef.js";const C={class:"accessory text-primary flex items-center"},R=w("span",null,"下载",-1),B=b({__name:"index",props:{fileName:{type:String,default:""},fileId:{type:Number,default:void 0},isDownLoad:{type:Boolean,default:!0},fileUrl:{type:String,default:""}},setup(o){const a=o,{proxy:n}=L(),i=v(new _),r=()=>d(this,null,function*(){if(a.fileUrl){const l=yield y({fileUrl:a.fileUrl,fileName:a.fileName}),t=URL.createObjectURL(l),e=document.createElement("a");e.style.display="none",e.href=t,e.download=a.fileName,document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(t)}else{const l=yield k({fileId:a.fileId}),t=URL.createObjectURL(l),e=document.createElement("a");e.style.display="none",e.href=t,e.download=a.fileName,document.body.appendChild(e),e.click(),document.body.removeChild(e),window.URL.revokeObjectURL(t)}}),c=()=>d(this,null,function*(){const l=["png","jpeg","jpg","gif","pdf"],t=a.fileName.split("."),e=t&&t[t.length-1];if(!l.includes(e)){n.$message.error("不支持此类型文件预览");return}const s=yield y({fileUrl:a.fileUrl,fileName:a.fileName}),U=URL.createObjectURL(s);i.data={id:a.fileId,title:a.fileName,fileUrl:U||""},i.visible=!0});return(l,t)=>(f(),p("div",C,[m(u,{name:"pdf-icon",class:"text-16 mr-8"}),w("span",{class:"cursor-pointer",onClick:c},N(o.fileName||"-"),1),o.isDownLoad?(f(),p("p",{key:0,class:"ml-24 flex items-center text-primary btn cursor-pointer",onClick:r},[m(u,{name:"down-icon",class:"mr-4 text-16"}),R])):g("",!0),m(x,{visible:i.visible,data:i.data,onClose:t[0]||(t[0]=e=>i.close(e))},null,8,["visible","data"])]))}});export{B as _};
