btt-ui 1.0.41 → 1.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -168,7 +168,7 @@ const K = { class: "k-upload-file-wrapper" }, P = { key: 0 }, Q = { class: "uplo
168
168
  ]),
169
169
  !n.isView && i.fileList.length > 0 && n.limit == 1 ? (l(), r("span", {
170
170
  key: 0,
171
- class: "k-file-icon-close",
171
+ class: "k-file-icon-close img-delete",
172
172
  onClick: s[0] || (s[0] = $((t) => w(0), ["stop"]))
173
173
  }, [
174
174
  L(g(p), {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("../../icon/index.js");require("./style/index.css");const h=require("./uploadFile2.js"),w=require("../../directives/drag.js"),L=require("../../directives/zoomIn.js"),v={class:"k-upload-file-wrapper"},z={key:0},A={class:"upload-btn-section"},b={class:"btn-box"},x={class:"img-sec-box"},D=["src"],$={class:"img-wrapper"},j=["src","title"],I=["src","title"],q=["src","title"],M=["onClick"],T=["onClick"],O={class:"k-file-extensions-desc"},R={key:0,class:"error-tip"},U={key:0},J={key:0,class:"k-upload-file-progress"},P=e.defineComponent({name:"k-upload-file"}),Z=e.defineComponent({...P,props:{data:{type:Array,default:()=>[]},isView:{type:Boolean,default:!0},accept:{type:Array,default:[".png",".jpg",".jpeg",".webp",".xls",".pdf",".xlsx",".docx"]},requestApi:{type:Function},limit:{type:Number,default:1},type:{type:String,default:"image"},params:{type:Object,default:{}},hasToken:{type:Boolean,default:!1},maxSize:{type:Number,default:10},successCode:{type:Number,default:200},loadingFileMaxSize:{type:Number,default:20}},emits:["limitError","success","deleteSuccess","fileSizeError"],setup(r,{expose:B,emit:F}){const g=e.ref();let m;const d=e.ref(!1),c=r;let N=c.maxSize*1024*1024;const V=c.loadingFileMaxSize*1024*1024,k=F,o=e.reactive({fileList:new Array,errFiles:new Array});o.fileList=c.data,e.watch(()=>c.data,t=>{o.fileList=t},{deep:!0});const S=t=>{for(let i=0;i<t.length;i++)t[i].size>V&&(d.value=!0)},y=()=>{m&&m.hide(),h.uploadImg({acceptType:c.accept,limit:c.limit,maxSize:N,success:async t=>{c.requestApi&&S(t),o.errFiles=new Array;let i=new Array;if(c.requestApi){let l=await c.requestApi(c.params,t);if(l.code==c.successCode){d.value&&(d.value=!1);for(let n=0;n<l.data.length;n++)i.push(l.data[n]);i.forEach(n=>{n.name=n.fileOriginName,n.type="image/"+n.fileSuffix}),E(i)}else console.log(l.msg)}else{for(let l=0;l<t.length;l++)t[l].url=window.URL.createObjectURL(t[l]),i.push(t[l]);E(i)}},limitError:t=>{k("limitError"),o.errFiles=new Array},fileSizeError:t=>{o.errFiles=t,k("fileSizeError",t)}})},E=t=>{c.limit==1?(o.fileList=t,c.type=="image"&&e.nextTick(()=>{m?m.updateSrc(s(o.fileList[0].url)):m=new L.ZoomIn(g.value,{type:"margin"})})):o.fileList=[...o.fileList,...t],k("success",o.fileList)};function C(t){const i=document.cookie.split("; ");for(let l=0;l<i.length;l++){const n=i[l].split("=");if(n[0]===t)return n[1]}return""}const s=t=>c.hasToken?`${t}?token=${C("bearer")}`:t,f=t=>{let i=o.fileList[t];o.fileList.splice(t,1),k("deleteSuccess",{deleteFile:i,result:o.fileList})},p=t=>{let i=new Array;o.fileList.forEach(n=>{let a=JSON.parse(JSON.stringify(n));a.url.indexOf("token=")<0&&(a.url=s(a.url)),i.push(a)}),new w.Dragger(t.target,{type:"margin",list:i}).build()};return B({clearFiles:()=>{o.fileList=new Array},deleteFile:f}),(t,i)=>(e.openBlock(),e.createElementBlock("div",v,[r.isView?e.createCommentVNode("",!0):e.renderSlot(t.$slots,"default",{key:0},()=>[r.type=="file"?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("span",{onClick:y},[e.renderSlot(t.$slots,"icon",{},()=>[e.createElementVNode("div",A,[e.createElementVNode("div",b,[e.createVNode(e.unref(u.Icon),{name:"download",color:"#cccccc",size:"20"}),i[1]||(i[1]=e.createElementVNode("span",null,"\u4E0A\u4F20\u9644\u4EF6",-1))])])])])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:"btn-file-image",onClick:e.withModifiers(y,["stop"])},[e.createElementVNode("div",x,[o.fileList.length>0&&r.limit==1?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(o.fileList[0].url),ref_key:"imgRef",ref:g},null,8,D)):e.createCommentVNode("",!0)]),!r.isView&&o.fileList.length>0&&r.limit==1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:i[0]||(i[0]=e.withModifiers(l=>f(0),["stop"]))},[e.createVNode(e.unref(u.Icon),{name:"close",size:"12"})])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"icon",{},()=>[o.fileList.length==0&&r.limit==1?(e.openBlock(),e.createBlock(e.unref(u.Icon),{key:0,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0),r.limit>1?(e.openBlock(),e.createBlock(e.unref(u.Icon),{key:1,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0)])]))]),e.renderSlot(t.$slots,"files",{data:o.fileList},()=>[r.type=="image"&&r.limit>1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[o.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-image-list",{"can-edit":!r.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,n)=>(e.openBlock(),e.createElementBlock("li",{key:n},[e.createElementVNode("div",$,[l.type=="image/webp"?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(l.url),onClick:p,title:l.name},null,8,j)):l.type=="image/png"?(e.openBlock(),e.createElementBlock("img",{key:1,src:s(l.url),onClick:p,title:l.name},null,8,I)):l.type=="image/jpg"||l.type=="image/jpeg"?(e.openBlock(),e.createElementBlock("img",{key:2,src:s(l.url),onClick:p,title:l.name},null,8,q)):e.createCommentVNode("",!0)]),r.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close img-delete",onClick:a=>f(n)},[e.createVNode(e.unref(u.Icon),{name:"close",size:"12"})],8,M))]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),r.type=="file"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[o.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-file-list",{"can-edit":!r.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,n)=>(e.openBlock(),e.createElementBlock("li",{key:n},[e.renderSlot(t.$slots,"file",{data:l},()=>[e.createElementVNode("span",null,e.toDisplayString(l.name),1),r.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:a=>f(n)},[e.createVNode(e.unref(u.Icon),{name:"delete",size:"12"})],8,T))])]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"tip",{},()=>[e.createElementVNode("div",O,"\u652F\u6301\u7684"+e.toDisplayString(r.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u683C\u5F0F\u6709\uFF1A"+e.toDisplayString(r.accept.join(","))+",\u6700\u591A\u4E0A\u4F20"+e.toDisplayString(r.limit)+"\u4E2A\u6587\u4EF6,"+e.toDisplayString(r.type=="file"?"\u5355\u4E2A\u6587\u4EF6":"\u5355\u5F20\u56FE\u7247")+"\u4E0D\u80FD\u5927\u4E8E"+e.toDisplayString(r.maxSize)+"MB",1)]),e.renderSlot(t.$slots,"sizeError",{data:o.errFiles},()=>[o.errFiles.length>0?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("span",null," \u8D85\u51FA\u5927\u5C0F\u9650\u5236\u7684"+e.toDisplayString(r.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u6709\uFF1A",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.errFiles,(l,n)=>(e.openBlock(),e.createElementBlock("span",{key:n},[n>0?(e.openBlock(),e.createElementBlock("span",U,", ")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(l.name),1)]))),128))])):e.createCommentVNode("",!0)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[d.value?(e.openBlock(),e.createElementBlock("div",J,[...i[2]||(i[2]=[e.createElementVNode("div",{class:"text"},"\u6587\u4EF6\u4E0A\u4F20\u4E2D,\u8BF7\u8010\u5FC3\u7B49\u5F85...",-1)])])):e.createCommentVNode("",!0)]))]))}});exports.default=Z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("../../icon/index.js");require("./style/index.css");const h=require("./uploadFile2.js"),w=require("../../directives/drag.js"),L=require("../../directives/zoomIn.js"),v={class:"k-upload-file-wrapper"},z={key:0},A={class:"upload-btn-section"},b={class:"btn-box"},x={class:"img-sec-box"},D=["src"],$={class:"img-wrapper"},j=["src","title"],I=["src","title"],q=["src","title"],M=["onClick"],T=["onClick"],O={class:"k-file-extensions-desc"},R={key:0,class:"error-tip"},U={key:0},J={key:0,class:"k-upload-file-progress"},P=e.defineComponent({name:"k-upload-file"}),Z=e.defineComponent({...P,props:{data:{type:Array,default:()=>[]},isView:{type:Boolean,default:!0},accept:{type:Array,default:[".png",".jpg",".jpeg",".webp",".xls",".pdf",".xlsx",".docx"]},requestApi:{type:Function},limit:{type:Number,default:1},type:{type:String,default:"image"},params:{type:Object,default:{}},hasToken:{type:Boolean,default:!1},maxSize:{type:Number,default:10},successCode:{type:Number,default:200},loadingFileMaxSize:{type:Number,default:20}},emits:["limitError","success","deleteSuccess","fileSizeError"],setup(r,{expose:B,emit:F}){const g=e.ref();let m;const d=e.ref(!1),c=r;let N=c.maxSize*1024*1024;const V=c.loadingFileMaxSize*1024*1024,k=F,o=e.reactive({fileList:new Array,errFiles:new Array});o.fileList=c.data,e.watch(()=>c.data,t=>{o.fileList=t},{deep:!0});const S=t=>{for(let i=0;i<t.length;i++)t[i].size>V&&(d.value=!0)},y=()=>{m&&m.hide(),h.uploadImg({acceptType:c.accept,limit:c.limit,maxSize:N,success:async t=>{c.requestApi&&S(t),o.errFiles=new Array;let i=new Array;if(c.requestApi){let l=await c.requestApi(c.params,t);if(l.code==c.successCode){d.value&&(d.value=!1);for(let n=0;n<l.data.length;n++)i.push(l.data[n]);i.forEach(n=>{n.name=n.fileOriginName,n.type="image/"+n.fileSuffix}),E(i)}else console.log(l.msg)}else{for(let l=0;l<t.length;l++)t[l].url=window.URL.createObjectURL(t[l]),i.push(t[l]);E(i)}},limitError:t=>{k("limitError"),o.errFiles=new Array},fileSizeError:t=>{o.errFiles=t,k("fileSizeError",t)}})},E=t=>{c.limit==1?(o.fileList=t,c.type=="image"&&e.nextTick(()=>{m?m.updateSrc(s(o.fileList[0].url)):m=new L.ZoomIn(g.value,{type:"margin"})})):o.fileList=[...o.fileList,...t],k("success",o.fileList)};function C(t){const i=document.cookie.split("; ");for(let l=0;l<i.length;l++){const n=i[l].split("=");if(n[0]===t)return n[1]}return""}const s=t=>c.hasToken?`${t}?token=${C("bearer")}`:t,f=t=>{let i=o.fileList[t];o.fileList.splice(t,1),k("deleteSuccess",{deleteFile:i,result:o.fileList})},p=t=>{let i=new Array;o.fileList.forEach(n=>{let a=JSON.parse(JSON.stringify(n));a.url.indexOf("token=")<0&&(a.url=s(a.url)),i.push(a)}),new w.Dragger(t.target,{type:"margin",list:i}).build()};return B({clearFiles:()=>{o.fileList=new Array},deleteFile:f}),(t,i)=>(e.openBlock(),e.createElementBlock("div",v,[r.isView?e.createCommentVNode("",!0):e.renderSlot(t.$slots,"default",{key:0},()=>[r.type=="file"?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("span",{onClick:y},[e.renderSlot(t.$slots,"icon",{},()=>[e.createElementVNode("div",A,[e.createElementVNode("div",b,[e.createVNode(e.unref(u.Icon),{name:"download",color:"#cccccc",size:"20"}),i[1]||(i[1]=e.createElementVNode("span",null,"\u4E0A\u4F20\u9644\u4EF6",-1))])])])])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:"btn-file-image",onClick:e.withModifiers(y,["stop"])},[e.createElementVNode("div",x,[o.fileList.length>0&&r.limit==1?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(o.fileList[0].url),ref_key:"imgRef",ref:g},null,8,D)):e.createCommentVNode("",!0)]),!r.isView&&o.fileList.length>0&&r.limit==1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close img-delete",onClick:i[0]||(i[0]=e.withModifiers(l=>f(0),["stop"]))},[e.createVNode(e.unref(u.Icon),{name:"close",size:"12"})])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"icon",{},()=>[o.fileList.length==0&&r.limit==1?(e.openBlock(),e.createBlock(e.unref(u.Icon),{key:0,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0),r.limit>1?(e.openBlock(),e.createBlock(e.unref(u.Icon),{key:1,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0)])]))]),e.renderSlot(t.$slots,"files",{data:o.fileList},()=>[r.type=="image"&&r.limit>1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[o.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-image-list",{"can-edit":!r.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,n)=>(e.openBlock(),e.createElementBlock("li",{key:n},[e.createElementVNode("div",$,[l.type=="image/webp"?(e.openBlock(),e.createElementBlock("img",{key:0,src:s(l.url),onClick:p,title:l.name},null,8,j)):l.type=="image/png"?(e.openBlock(),e.createElementBlock("img",{key:1,src:s(l.url),onClick:p,title:l.name},null,8,I)):l.type=="image/jpg"||l.type=="image/jpeg"?(e.openBlock(),e.createElementBlock("img",{key:2,src:s(l.url),onClick:p,title:l.name},null,8,q)):e.createCommentVNode("",!0)]),r.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close img-delete",onClick:a=>f(n)},[e.createVNode(e.unref(u.Icon),{name:"close",size:"12"})],8,M))]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),r.type=="file"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[o.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-file-list",{"can-edit":!r.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,n)=>(e.openBlock(),e.createElementBlock("li",{key:n},[e.renderSlot(t.$slots,"file",{data:l},()=>[e.createElementVNode("span",null,e.toDisplayString(l.name),1),r.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:a=>f(n)},[e.createVNode(e.unref(u.Icon),{name:"delete",size:"12"})],8,T))])]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"tip",{},()=>[e.createElementVNode("div",O,"\u652F\u6301\u7684"+e.toDisplayString(r.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u683C\u5F0F\u6709\uFF1A"+e.toDisplayString(r.accept.join(","))+",\u6700\u591A\u4E0A\u4F20"+e.toDisplayString(r.limit)+"\u4E2A\u6587\u4EF6,"+e.toDisplayString(r.type=="file"?"\u5355\u4E2A\u6587\u4EF6":"\u5355\u5F20\u56FE\u7247")+"\u4E0D\u80FD\u5927\u4E8E"+e.toDisplayString(r.maxSize)+"MB",1)]),e.renderSlot(t.$slots,"sizeError",{data:o.errFiles},()=>[o.errFiles.length>0?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("span",null," \u8D85\u51FA\u5927\u5C0F\u9650\u5236\u7684"+e.toDisplayString(r.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u6709\uFF1A",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.errFiles,(l,n)=>(e.openBlock(),e.createElementBlock("span",{key:n},[n>0?(e.openBlock(),e.createElementBlock("span",U,", ")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(l.name),1)]))),128))])):e.createCommentVNode("",!0)]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[d.value?(e.openBlock(),e.createElementBlock("div",J,[...i[2]||(i[2]=[e.createElementVNode("div",{class:"text"},"\u6587\u4EF6\u4E0A\u4F20\u4E2D,\u8BF7\u8010\u5FC3\u7B49\u5F85...",-1)])])):e.createCommentVNode("",!0)]))]))}});exports.default=Z;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btt-ui",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [