物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
2.8 KiB

  1. import{g as L,$ as U,d as C,r as d,N as _,D as y,E as i,F as c,G as j,I as p,L as g}from"./index-3c234266.js";import{A as w,_ as P}from"./_plugin-vue_export-helper-a1ffee7e.js";import{P as k,d as T}from"./PlusOutlined-920ae6ab.js";function h(e){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?Object(arguments[a]):{},l=Object.keys(n);typeof Object.getOwnPropertySymbols=="function"&&(l=l.concat(Object.getOwnPropertySymbols(n).filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable}))),l.forEach(function(s){$(e,s,n[s])})}return e}function $(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}var f=function(a,n){var l=h({},a,n.attrs);return L(w,h({},l,{icon:U}),null)};f.displayName="LoadingOutlined";f.inheritAttrs=!1;const A=f;function O(e,a){const n=new FileReader;n.addEventListener("load",()=>a(n.result)),n.readAsDataURL(e)}function B(e,a){const n=new FileReader;n.readAsText(e),n.onload=l=>{a(n.result)}}const E=C({components:{LoadingOutlined:A,PlusOutlined:k},emits:["fileChanged"],setup(e,{emit:a}){const n=d([]),l=d(!1),s=d(""),r=d("");return{fileList:n,loading:l,imageUrl:s,imageType:r,handleChange:t=>{const o=t.file.type;o.includes("svg")?r.value="svg":o.includes("jpeg")?r.value="jpeg":o.includes("jpg")?r.value="jpg":o.includes("png")&&(r.value="png"),o!=null&&o.includes("svg")?B(t.file,u=>{s.value=`data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(u)))}`,l.value=!1,a("fileChanged",{imageUrl:u,imageType:r.value})}):O(t.file,u=>{s.value=u,l.value=!1,a("fileChanged",{imageUrl:s.value,imageType:r.value})})},beforeUpload:t=>{if(O(t,b=>{s.value=b}),!(t.type.includes("jpg")||t.type.includes("jpeg")||t.type.includes("png")||t.type.includes("svg"))){_.error("只能上传jpg, jpeg, png 和 svg 等格式");return}if(!(t.size/1024/1024<2)){_.error("图标尺寸不能大于 2MB!");return}return!1}}}});const F=["src"],S=["src"],I={key:2},N={key:2,class:"ant-upload-text"};function R(e,a,n,l,s,r){const m=y("LoadingOutlined"),v=y("PlusOutlined"),t=T;return i(),c(t,{"file-list":e.fileList,"onUpdate:fileList":a[0]||(a[0]=o=>e.fileList=o),name:"avatar","list-type":"picture-card",class:"avatar-uploader","max-count":1,"show-upload-list":!1,action:"","before-upload":e.beforeUpload,onChange:e.handleChange},{default:j(()=>[e.imageUrl&&e.imageType!=="svg"?(i(),p("img",{key:0,src:e.imageUrl,class:"w-auto h-full",alt:"avatar"},null,8,F)):g("",!0),e.imageUrl&&e.imageType==="svg"?(i(),p("img",{key:1,src:e.imageUrl,class:"w-auto h-full",alt:"avatar"},null,8,S)):(i(),p("div",I,[e.loading?(i(),c(m,{key:0})):e.imageUrl?g("",!0):(i(),c(v,{key:1})),e.imageUrl?g("",!0):(i(),p("div",N," 上传 "))]))]),_:1},8,["file-list","before-upload","onChange"])}const z=P(E,[["render",R],["__scopeId","data-v-6d52c721"]]);export{z as U};