btt-ui 1.0.36 → 1.0.38

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.
@@ -1,16 +1,20 @@
1
- import { defineComponent as $, ref as z, reactive as B, watch as D, openBlock as l, createElementBlock as s, renderSlot as d, createElementVNode as c, createVNode as h, unref as y, withModifiers as S, createCommentVNode as n, createBlock as b, Fragment as p, normalizeClass as V, renderList as L, toDisplayString as m, createTextVNode as I, nextTick as R } from "vue";
2
- import { Icon as g } from "../../icon/index.mjs";
1
+ import { defineComponent as V, ref as b, reactive as R, watch as q, openBlock as l, createElementBlock as s, renderSlot as m, createElementVNode as c, createVNode as w, unref as f, withModifiers as x, createCommentVNode as u, createBlock as z, Fragment as k, normalizeClass as $, renderList as v, toDisplayString as d, createTextVNode as O, Teleport as U, nextTick as Z } from "vue";
2
+ import { Icon as y } from "../../icon/index.mjs";
3
3
  import "./style/index.css";
4
- import { uploadImg as q } from "./uploadFile2.mjs";
5
- import { Dragger as T } from "../../directives/drag.mjs";
6
- import { ZoomIn as M } from "../../directives/zoomIn.mjs";
7
- const O = { class: "k-upload-file-wrapper" }, U = { key: 0 }, Z = { class: "upload-btn-section" }, G = { class: "btn-box" }, H = { class: "img-sec-box" }, J = ["src"], K = { class: "img-wrapper" }, P = ["src", "title"], Q = ["src", "title"], W = ["src", "title"], X = ["onClick"], Y = ["onClick"], _ = { class: "k-file-extensions-desc" }, ee = {
4
+ import { uploadImg as G } from "./uploadFile2.mjs";
5
+ import { Dragger as H } from "../../directives/drag.mjs";
6
+ import { ZoomIn as J } from "../../directives/zoomIn.mjs";
7
+ import "./uploadFile.vue?vue&type=style&index=0&lang.css";
8
+ const K = { class: "k-upload-file-wrapper" }, P = { key: 0 }, Q = { class: "upload-btn-section" }, W = { class: "btn-box" }, X = { class: "img-sec-box" }, Y = ["src"], _ = { class: "img-wrapper" }, ee = ["src", "title"], te = ["src", "title"], ie = ["src", "title"], le = ["onClick"], se = ["onClick"], oe = { class: "k-file-extensions-desc" }, re = {
8
9
  key: 0,
9
10
  class: "error-tip"
10
- }, te = { key: 0 }, ie = $({
11
+ }, ne = { key: 0 }, ue = {
12
+ key: 0,
13
+ class: "upload-file-progress"
14
+ }, ae = V({
11
15
  name: "k-upload-file"
12
- }), oe = $({
13
- ...ie,
16
+ }), ke = V({
17
+ ...ae,
14
18
  props: {
15
19
  data: {
16
20
  type: Array,
@@ -39,6 +43,10 @@ const O = { class: "k-upload-file-wrapper" }, U = { key: 0 }, Z = { class: "uplo
39
43
  type: Object,
40
44
  default: {}
41
45
  },
46
+ hasToken: {
47
+ type: Boolean,
48
+ default: !1
49
+ },
42
50
  maxSize: {
43
51
  type: Number,
44
52
  default: 10
@@ -46,78 +54,98 @@ const O = { class: "k-upload-file-wrapper" }, U = { key: 0 }, Z = { class: "uplo
46
54
  successCode: {
47
55
  type: Number,
48
56
  default: 200
57
+ },
58
+ loadingFileMaxSize: {
59
+ type: Number,
60
+ default: 20
49
61
  }
50
62
  },
51
63
  emits: ["limitError", "success", "deleteSuccess", "fileSizeError"],
52
- setup(r, { expose: x, emit: j }) {
53
- const E = z();
54
- let f, A = z(1024 * 1024 * 10);
55
- const o = r;
56
- A.value = o.maxSize * 1024 * 1024;
57
- const k = j, e = B({
64
+ setup(r, { expose: B, emit: N }) {
65
+ const A = b();
66
+ let g;
67
+ const F = b(!1), a = r;
68
+ let j = a.maxSize * 1024 * 1024;
69
+ const T = a.loadingFileMaxSize * 1024 * 1024, h = N, i = R({
58
70
  fileList: new Array(),
59
71
  errFiles: new Array()
60
72
  });
61
- e.fileList = o.data, D(() => o.data, (t) => {
62
- e.fileList = t;
73
+ i.fileList = a.data, q(() => a.data, (e) => {
74
+ i.fileList = e;
63
75
  }, { deep: !0 });
64
- const C = () => {
65
- f && f.hide(), q({
66
- acceptType: o.accept,
67
- limit: o.limit,
68
- maxSize: A.value,
69
- success: async (t) => {
70
- e.errFiles = new Array();
71
- let u = new Array();
72
- if (o.requestApi) {
73
- let i = await o.requestApi(o.params, t);
74
- if (i.code == o.successCode) {
75
- for (let a = 0; a < i.data.length; a++)
76
- u.push(i.data[a]);
77
- v(u);
76
+ const D = (e) => {
77
+ for (let o = 0; o < e.length; o++)
78
+ e[o].size > T && (F.value = !0);
79
+ }, C = () => {
80
+ g && g.hide(), G({
81
+ acceptType: a.accept,
82
+ limit: a.limit,
83
+ maxSize: j,
84
+ success: async (e) => {
85
+ D(e), i.errFiles = new Array();
86
+ let o = new Array();
87
+ if (a.requestApi) {
88
+ let t = await a.requestApi(a.params, e);
89
+ if (t.code == a.successCode) {
90
+ F.value && (F.value = !1);
91
+ for (let n = 0; n < t.data.length; n++)
92
+ o.push(t.data[n]);
93
+ o.forEach((n) => {
94
+ n.name = n.fileOriginName, n.type = "image/" + n.fileSuffix;
95
+ }), S(o);
78
96
  } else
79
- console.log(i.msg);
97
+ console.log(t.msg);
80
98
  } else {
81
- for (let i = 0; i < t.length; i++)
82
- t[i].url = window.URL.createObjectURL(t[i]), u.push(t[i]);
83
- v(u);
99
+ for (let t = 0; t < e.length; t++)
100
+ e[t].url = window.URL.createObjectURL(e[t]), o.push(e[t]);
101
+ S(o);
84
102
  }
85
103
  },
86
- limitError: (t) => {
87
- k("limitError"), e.errFiles = new Array();
104
+ limitError: (e) => {
105
+ h("limitError"), i.errFiles = new Array();
88
106
  },
89
- fileSizeError: (t) => {
90
- e.errFiles = t, k("fileSizeError", t);
107
+ fileSizeError: (e) => {
108
+ i.errFiles = e, h("fileSizeError", e);
91
109
  }
92
110
  });
93
- }, v = (t) => {
94
- o.limit == 1 ? (e.fileList = t, o.type == "image" && R(() => {
95
- f || (f = new M(E.value, { type: "margin" })), f && f.updateSrc(e.fileList[0].url);
96
- })) : e.fileList = [...e.fileList, ...t], k("success", e.fileList);
97
- }, F = (t) => {
98
- let u = e.fileList[t];
99
- e.fileList.splice(t, 1), k("deleteSuccess", { deleteFile: u, result: e.fileList });
100
- }, w = (t) => {
101
- new T(t.target, { type: "margin", list: e.fileList }).build();
111
+ }, S = (e) => {
112
+ a.limit == 1 ? (i.fileList = e, a.type == "image" && Z(() => {
113
+ g ? g.updateSrc(p(i.fileList[0].url)) : g = new J(A.value, { type: "margin" });
114
+ })) : i.fileList = [...i.fileList, ...e], h("success", i.fileList);
115
+ };
116
+ function I(e) {
117
+ const o = document.cookie.split("; ");
118
+ for (let t = 0; t < o.length; t++) {
119
+ const n = o[t].split("=");
120
+ if (n[0] === e)
121
+ return n[1];
122
+ }
123
+ return "";
124
+ }
125
+ const p = (e) => a.hasToken ? `${e}?token=${I("bearer")}` : e, E = (e) => {
126
+ let o = i.fileList[e];
127
+ i.fileList.splice(e, 1), h("deleteSuccess", { deleteFile: o, result: i.fileList });
128
+ }, L = (e) => {
129
+ new H(e.target, { type: "margin", list: i.fileList }).build();
102
130
  };
103
- return x({
131
+ return B({
104
132
  clearFiles: () => {
105
- e.fileList = new Array();
133
+ i.fileList = new Array();
106
134
  },
107
- deleteFile: F
108
- }), (t, u) => (l(), s("div", O, [
109
- r.isView ? n("", !0) : d(t.$slots, "default", { key: 0 }, () => [
110
- r.type == "file" ? (l(), s("div", U, [
135
+ deleteFile: E
136
+ }), (e, o) => (l(), s("div", K, [
137
+ r.isView ? u("", !0) : m(e.$slots, "default", { key: 0 }, () => [
138
+ r.type == "file" ? (l(), s("div", P, [
111
139
  c("span", { onClick: C }, [
112
- d(t.$slots, "icon", {}, () => [
113
- c("div", Z, [
114
- c("div", G, [
115
- h(y(g), {
140
+ m(e.$slots, "icon", {}, () => [
141
+ c("div", Q, [
142
+ c("div", W, [
143
+ w(f(y), {
116
144
  name: "download",
117
145
  color: "#cccccc",
118
146
  size: "20"
119
147
  }),
120
- u[1] || (u[1] = c("span", null, "\u4E0A\u4F20\u9644\u4EF6", -1))
148
+ o[1] || (o[1] = c("span", null, "\u4E0A\u4F20\u9644\u4EF6", -1))
121
149
  ])
122
150
  ])
123
151
  ])
@@ -125,120 +153,125 @@ const O = { class: "k-upload-file-wrapper" }, U = { key: 0 }, Z = { class: "uplo
125
153
  ])) : (l(), s("div", {
126
154
  key: 1,
127
155
  class: "btn-file-image",
128
- onClick: S(C, ["stop"])
156
+ onClick: x(C, ["stop"])
129
157
  }, [
130
- c("div", H, [
131
- e.fileList.length > 0 && r.limit == 1 ? (l(), s("img", {
158
+ c("div", X, [
159
+ i.fileList.length > 0 && r.limit == 1 ? (l(), s("img", {
132
160
  key: 0,
133
- src: e.fileList[0].url,
161
+ src: p(i.fileList[0].url),
134
162
  ref_key: "imgRef",
135
- ref: E
136
- }, null, 8, J)) : n("", !0)
163
+ ref: A
164
+ }, null, 8, Y)) : u("", !0)
137
165
  ]),
138
- !r.isView && e.fileList.length > 0 && r.limit == 1 ? (l(), s("span", {
166
+ !r.isView && i.fileList.length > 0 && r.limit == 1 ? (l(), s("span", {
139
167
  key: 0,
140
168
  class: "k-file-icon-close",
141
- onClick: u[0] || (u[0] = S((i) => F(0), ["stop"]))
169
+ onClick: o[0] || (o[0] = x((t) => E(0), ["stop"]))
142
170
  }, [
143
- h(y(g), {
171
+ w(f(y), {
144
172
  name: "close",
145
173
  size: "12"
146
174
  })
147
- ])) : n("", !0),
148
- d(t.$slots, "icon", {}, () => [
149
- e.fileList.length == 0 && r.limit == 1 ? (l(), b(y(g), {
175
+ ])) : u("", !0),
176
+ m(e.$slots, "icon", {}, () => [
177
+ i.fileList.length == 0 && r.limit == 1 ? (l(), z(f(y), {
150
178
  key: 0,
151
179
  name: "plus",
152
180
  color: "#409eff"
153
- })) : n("", !0),
154
- r.limit > 1 ? (l(), b(y(g), {
181
+ })) : u("", !0),
182
+ r.limit > 1 ? (l(), z(f(y), {
155
183
  key: 1,
156
184
  name: "plus",
157
185
  color: "#409eff"
158
- })) : n("", !0)
186
+ })) : u("", !0)
159
187
  ])
160
188
  ]))
161
189
  ]),
162
- d(t.$slots, "files", {
163
- data: e.fileList
190
+ m(e.$slots, "files", {
191
+ data: i.fileList
164
192
  }, () => [
165
- r.type == "image" && r.limit > 1 ? (l(), s(p, { key: 0 }, [
166
- e.fileList.length > 0 ? (l(), s("ul", {
193
+ r.type == "image" && r.limit > 1 ? (l(), s(k, { key: 0 }, [
194
+ i.fileList.length > 0 ? (l(), s("ul", {
167
195
  key: 0,
168
- class: V(["k-image-list", { "can-edit": !r.isView }])
196
+ class: $(["k-image-list", { "can-edit": !r.isView }])
169
197
  }, [
170
- (l(!0), s(p, null, L(e.fileList, (i, a) => (l(), s("li", { key: a }, [
171
- c("div", K, [
172
- i.type == "image/webp" ? (l(), s("img", {
198
+ (l(!0), s(k, null, v(i.fileList, (t, n) => (l(), s("li", { key: n }, [
199
+ c("div", _, [
200
+ t.type == "image/webp" ? (l(), s("img", {
173
201
  key: 0,
174
- src: i.url,
175
- onClick: w,
176
- title: i.name
177
- }, null, 8, P)) : i.type == "image/png" ? (l(), s("img", {
202
+ src: p(t.url),
203
+ onClick: L,
204
+ title: t.name
205
+ }, null, 8, ee)) : t.type == "image/png" ? (l(), s("img", {
178
206
  key: 1,
179
- src: i.url,
180
- onClick: w,
181
- title: i.name
182
- }, null, 8, Q)) : i.type == "image/jpg" || i.type == "image/jpeg" ? (l(), s("img", {
207
+ src: p(t.url),
208
+ onClick: L,
209
+ title: t.name
210
+ }, null, 8, te)) : t.type == "image/jpg" || t.type == "image/jpeg" ? (l(), s("img", {
183
211
  key: 2,
184
- src: i.url,
185
- onClick: w,
186
- title: i.name
187
- }, null, 8, W)) : n("", !0)
212
+ src: p(t.url),
213
+ onClick: L,
214
+ title: t.name
215
+ }, null, 8, ie)) : u("", !0)
188
216
  ]),
189
- r.isView ? n("", !0) : (l(), s("span", {
217
+ r.isView ? u("", !0) : (l(), s("span", {
190
218
  key: 0,
191
219
  class: "k-file-icon-close",
192
- onClick: (N) => F(a)
220
+ onClick: (M) => E(n)
193
221
  }, [
194
- h(y(g), {
222
+ w(f(y), {
195
223
  name: "close",
196
224
  size: "12"
197
225
  })
198
- ], 8, X))
226
+ ], 8, le))
199
227
  ]))), 128))
200
- ], 2)) : n("", !0)
201
- ], 64)) : n("", !0),
202
- r.type == "file" ? (l(), s(p, { key: 1 }, [
203
- e.fileList.length > 0 ? (l(), s("ul", {
228
+ ], 2)) : u("", !0)
229
+ ], 64)) : u("", !0),
230
+ r.type == "file" ? (l(), s(k, { key: 1 }, [
231
+ i.fileList.length > 0 ? (l(), s("ul", {
204
232
  key: 0,
205
- class: V(["k-file-list", { "can-edit": !r.isView }])
233
+ class: $(["k-file-list", { "can-edit": !r.isView }])
206
234
  }, [
207
- (l(!0), s(p, null, L(e.fileList, (i, a) => (l(), s("li", { key: a }, [
208
- d(t.$slots, "file", { data: i }, () => [
209
- c("span", null, m(i.name), 1),
210
- r.isView ? n("", !0) : (l(), s("span", {
235
+ (l(!0), s(k, null, v(i.fileList, (t, n) => (l(), s("li", { key: n }, [
236
+ m(e.$slots, "file", { data: t }, () => [
237
+ c("span", null, d(t.name), 1),
238
+ r.isView ? u("", !0) : (l(), s("span", {
211
239
  key: 0,
212
240
  class: "k-file-icon-close",
213
- onClick: (N) => F(a)
241
+ onClick: (M) => E(n)
214
242
  }, [
215
- h(y(g), {
243
+ w(f(y), {
216
244
  name: "close",
217
245
  size: "12"
218
246
  })
219
- ], 8, Y))
247
+ ], 8, se))
220
248
  ])
221
249
  ]))), 128))
222
- ], 2)) : n("", !0)
223
- ], 64)) : n("", !0)
250
+ ], 2)) : u("", !0)
251
+ ], 64)) : u("", !0)
224
252
  ]),
225
- d(t.$slots, "tip", {}, () => [
226
- c("div", _, "\u652F\u6301\u7684" + m(r.type == "file" ? "\u6587\u4EF6" : "\u56FE\u7247") + "\u683C\u5F0F\u6709\uFF1A" + m(r.accept.join(",")) + ",\u6700\u591A\u4E0A\u4F20" + m(r.limit) + "\u4E2A\u6587\u4EF6," + m(r.type == "file" ? "\u5355\u4E2A\u6587\u4EF6" : "\u5355\u5F20\u56FE\u7247") + "\u4E0D\u80FD\u5927\u4E8E" + m(r.maxSize) + "MB", 1)
253
+ m(e.$slots, "tip", {}, () => [
254
+ c("div", oe, "\u652F\u6301\u7684" + d(r.type == "file" ? "\u6587\u4EF6" : "\u56FE\u7247") + "\u683C\u5F0F\u6709\uFF1A" + d(r.accept.join(",")) + ",\u6700\u591A\u4E0A\u4F20" + d(r.limit) + "\u4E2A\u6587\u4EF6," + d(r.type == "file" ? "\u5355\u4E2A\u6587\u4EF6" : "\u5355\u5F20\u56FE\u7247") + "\u4E0D\u80FD\u5927\u4E8E" + d(r.maxSize) + "MB", 1)
227
255
  ]),
228
- d(t.$slots, "sizeError", {
229
- data: e.errFiles
256
+ m(e.$slots, "sizeError", {
257
+ data: i.errFiles
230
258
  }, () => [
231
- e.errFiles.length > 0 ? (l(), s("div", ee, [
232
- c("span", null, " \u8D85\u51FA\u5927\u5C0F\u9650\u5236\u7684" + m(r.type == "file" ? "\u6587\u4EF6" : "\u56FE\u7247") + "\u6709\uFF1A", 1),
233
- (l(!0), s(p, null, L(e.errFiles, (i, a) => (l(), s("span", { key: a }, [
234
- a > 0 ? (l(), s("span", te, ", ")) : n("", !0),
235
- I(" " + m(i.name), 1)
259
+ i.errFiles.length > 0 ? (l(), s("div", re, [
260
+ c("span", null, " \u8D85\u51FA\u5927\u5C0F\u9650\u5236\u7684" + d(r.type == "file" ? "\u6587\u4EF6" : "\u56FE\u7247") + "\u6709\uFF1A", 1),
261
+ (l(!0), s(k, null, v(i.errFiles, (t, n) => (l(), s("span", { key: n }, [
262
+ n > 0 ? (l(), s("span", ne, ", ")) : u("", !0),
263
+ O(" " + d(t.name), 1)
236
264
  ]))), 128))
237
- ])) : n("", !0)
238
- ])
265
+ ])) : u("", !0)
266
+ ]),
267
+ (l(), z(U, { to: "body" }, [
268
+ F.value ? (l(), s("div", ue, [...o[2] || (o[2] = [
269
+ c("div", { class: "text" }, "\u6587\u4EF6\u4E0A\u4F20\u4E2D,\u8BF7\u8010\u5FC3\u7B49\u5F85...", -1)
270
+ ])])) : u("", !0)
271
+ ]))
239
272
  ]));
240
273
  }
241
274
  });
242
275
  export {
243
- oe as default
276
+ ke as default
244
277
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("../../icon/index.js");require("./style/index.css");const F=require("./uploadFile2.js"),V=require("../../directives/drag.js"),C=require("../../directives/zoomIn.js"),N={class:"k-upload-file-wrapper"},S={key:0},h={class:"upload-btn-section"},L={class:"btn-box"},w={class:"img-sec-box"},v=["src"],z={class:"img-wrapper"},A=["src","title"],b=["src","title"],j=["src","title"],D=["onClick"],I=["onClick"],x={class:"k-file-extensions-desc"},$={key:0,class:"error-tip"},q={key:0},M=e.defineComponent({name:"k-upload-file"}),R=e.defineComponent({...M,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:{}},maxSize:{type:Number,default:10},successCode:{type:Number,default:200}},emits:["limitError","success","deleteSuccess","fileSizeError"],setup(o,{expose:g,emit:E}){const k=e.ref();let s,p=e.ref(1024*1024*10);const c=o;p.value=c.maxSize*1024*1024;const u=E,t=e.reactive({fileList:new Array,errFiles:new Array});t.fileList=c.data,e.watch(()=>c.data,l=>{t.fileList=l},{deep:!0});const f=()=>{s&&s.hide(),F.uploadImg({acceptType:c.accept,limit:c.limit,maxSize:p.value,success:async l=>{t.errFiles=new Array;let n=new Array;if(c.requestApi){let i=await c.requestApi(c.params,l);if(i.code==c.successCode){for(let r=0;r<i.data.length;r++)n.push(i.data[r]);y(n)}else console.log(i.msg)}else{for(let i=0;i<l.length;i++)l[i].url=window.URL.createObjectURL(l[i]),n.push(l[i]);y(n)}},limitError:l=>{u("limitError"),t.errFiles=new Array},fileSizeError:l=>{t.errFiles=l,u("fileSizeError",l)}})},y=l=>{c.limit==1?(t.fileList=l,c.type=="image"&&e.nextTick(()=>{s||(s=new C.ZoomIn(k.value,{type:"margin"})),s&&s.updateSrc(t.fileList[0].url)})):t.fileList=[...t.fileList,...l],u("success",t.fileList)},m=l=>{let n=t.fileList[l];t.fileList.splice(l,1),u("deleteSuccess",{deleteFile:n,result:t.fileList})},d=l=>{new V.Dragger(l.target,{type:"margin",list:t.fileList}).build()};return g({clearFiles:()=>{t.fileList=new Array},deleteFile:m}),(l,n)=>(e.openBlock(),e.createElementBlock("div",N,[o.isView?e.createCommentVNode("",!0):e.renderSlot(l.$slots,"default",{key:0},()=>[o.type=="file"?(e.openBlock(),e.createElementBlock("div",S,[e.createElementVNode("span",{onClick:f},[e.renderSlot(l.$slots,"icon",{},()=>[e.createElementVNode("div",h,[e.createElementVNode("div",L,[e.createVNode(e.unref(a.Icon),{name:"download",color:"#cccccc",size:"20"}),n[1]||(n[1]=e.createElementVNode("span",null,"\u4E0A\u4F20\u9644\u4EF6",-1))])])])])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:"btn-file-image",onClick:e.withModifiers(f,["stop"])},[e.createElementVNode("div",w,[t.fileList.length>0&&o.limit==1?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.fileList[0].url,ref_key:"imgRef",ref:k},null,8,v)):e.createCommentVNode("",!0)]),!o.isView&&t.fileList.length>0&&o.limit==1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:n[0]||(n[0]=e.withModifiers(i=>m(0),["stop"]))},[e.createVNode(e.unref(a.Icon),{name:"close",size:"12"})])):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"icon",{},()=>[t.fileList.length==0&&o.limit==1?(e.openBlock(),e.createBlock(e.unref(a.Icon),{key:0,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0),o.limit>1?(e.openBlock(),e.createBlock(e.unref(a.Icon),{key:1,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0)])]))]),e.renderSlot(l.$slots,"files",{data:t.fileList},()=>[o.type=="image"&&o.limit>1?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-image-list",{"can-edit":!o.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fileList,(i,r)=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.createElementVNode("div",z,[i.type=="image/webp"?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.url,onClick:d,title:i.name},null,8,A)):i.type=="image/png"?(e.openBlock(),e.createElementBlock("img",{key:1,src:i.url,onClick:d,title:i.name},null,8,b)):i.type=="image/jpg"||i.type=="image/jpeg"?(e.openBlock(),e.createElementBlock("img",{key:2,src:i.url,onClick:d,title:i.name},null,8,j)):e.createCommentVNode("",!0)]),o.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:B=>m(r)},[e.createVNode(e.unref(a.Icon),{name:"close",size:"12"})],8,D))]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),o.type=="file"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t.fileList.length>0?(e.openBlock(),e.createElementBlock("ul",{key:0,class:e.normalizeClass(["k-file-list",{"can-edit":!o.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fileList,(i,r)=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.renderSlot(l.$slots,"file",{data:i},()=>[e.createElementVNode("span",null,e.toDisplayString(i.name),1),o.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:B=>m(r)},[e.createVNode(e.unref(a.Icon),{name:"close",size:"12"})],8,I))])]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)]),e.renderSlot(l.$slots,"tip",{},()=>[e.createElementVNode("div",x,"\u652F\u6301\u7684"+e.toDisplayString(o.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u683C\u5F0F\u6709\uFF1A"+e.toDisplayString(o.accept.join(","))+",\u6700\u591A\u4E0A\u4F20"+e.toDisplayString(o.limit)+"\u4E2A\u6587\u4EF6,"+e.toDisplayString(o.type=="file"?"\u5355\u4E2A\u6587\u4EF6":"\u5355\u5F20\u56FE\u7247")+"\u4E0D\u80FD\u5927\u4E8E"+e.toDisplayString(o.maxSize)+"MB",1)]),e.renderSlot(l.$slots,"sizeError",{data:t.errFiles},()=>[t.errFiles.length>0?(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("span",null," \u8D85\u51FA\u5927\u5C0F\u9650\u5236\u7684"+e.toDisplayString(o.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u6709\uFF1A",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.errFiles,(i,r)=>(e.openBlock(),e.createElementBlock("span",{key:r},[r>0?(e.openBlock(),e.createElementBlock("span",q,", ")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(i.name),1)]))),128))])):e.createCommentVNode("",!0)])]))}});exports.default=R;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("../../icon/index.js");require("./style/index.css");const h=require("./uploadFile2.js"),v=require("../../directives/drag.js"),L=require("../../directives/zoomIn.js");require("./uploadFile.vue?vue&type=style&index=0&lang.css");const w={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},P={key:0,class:"upload-file-progress"},Z=e.defineComponent({name:"k-upload-file"}),G=e.defineComponent({...Z,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(n,{expose:E,emit:B}){const f=e.ref();let a;const m=e.ref(!1),c=n;let F=c.maxSize*1024*1024;const V=c.loadingFileMaxSize*1024*1024,d=B,o=e.reactive({fileList:new Array,errFiles:new Array});o.fileList=c.data,e.watch(()=>c.data,t=>{o.fileList=t},{deep:!0});const C=t=>{for(let i=0;i<t.length;i++)t[i].size>V&&(m.value=!0)},g=()=>{a&&a.hide(),h.uploadImg({acceptType:c.accept,limit:c.limit,maxSize:F,success:async t=>{C(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){m.value&&(m.value=!1);for(let r=0;r<l.data.length;r++)i.push(l.data[r]);i.forEach(r=>{r.name=r.fileOriginName,r.type="image/"+r.fileSuffix}),y(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]);y(i)}},limitError:t=>{d("limitError"),o.errFiles=new Array},fileSizeError:t=>{o.errFiles=t,d("fileSizeError",t)}})},y=t=>{c.limit==1?(o.fileList=t,c.type=="image"&&e.nextTick(()=>{a?a.updateSrc(u(o.fileList[0].url)):a=new L.ZoomIn(f.value,{type:"margin"})})):o.fileList=[...o.fileList,...t],d("success",o.fileList)};function N(t){const i=document.cookie.split("; ");for(let l=0;l<i.length;l++){const r=i[l].split("=");if(r[0]===t)return r[1]}return""}const u=t=>c.hasToken?`${t}?token=${N("bearer")}`:t,k=t=>{let i=o.fileList[t];o.fileList.splice(t,1),d("deleteSuccess",{deleteFile:i,result:o.fileList})},p=t=>{new v.Dragger(t.target,{type:"margin",list:o.fileList}).build()};return E({clearFiles:()=>{o.fileList=new Array},deleteFile:k}),(t,i)=>(e.openBlock(),e.createElementBlock("div",w,[n.isView?e.createCommentVNode("",!0):e.renderSlot(t.$slots,"default",{key:0},()=>[n.type=="file"?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("span",{onClick:g},[e.renderSlot(t.$slots,"icon",{},()=>[e.createElementVNode("div",A,[e.createElementVNode("div",b,[e.createVNode(e.unref(s.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(g,["stop"])},[e.createElementVNode("div",x,[o.fileList.length>0&&n.limit==1?(e.openBlock(),e.createElementBlock("img",{key:0,src:u(o.fileList[0].url),ref_key:"imgRef",ref:f},null,8,D)):e.createCommentVNode("",!0)]),!n.isView&&o.fileList.length>0&&n.limit==1?(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:i[0]||(i[0]=e.withModifiers(l=>k(0),["stop"]))},[e.createVNode(e.unref(s.Icon),{name:"close",size:"12"})])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"icon",{},()=>[o.fileList.length==0&&n.limit==1?(e.openBlock(),e.createBlock(e.unref(s.Icon),{key:0,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0),n.limit>1?(e.openBlock(),e.createBlock(e.unref(s.Icon),{key:1,name:"plus",color:"#409eff"})):e.createCommentVNode("",!0)])]))]),e.renderSlot(t.$slots,"files",{data:o.fileList},()=>[n.type=="image"&&n.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":!n.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,r)=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.createElementVNode("div",$,[l.type=="image/webp"?(e.openBlock(),e.createElementBlock("img",{key:0,src:u(l.url),onClick:p,title:l.name},null,8,j)):l.type=="image/png"?(e.openBlock(),e.createElementBlock("img",{key:1,src:u(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:u(l.url),onClick:p,title:l.name},null,8,q)):e.createCommentVNode("",!0)]),n.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:S=>k(r)},[e.createVNode(e.unref(s.Icon),{name:"close",size:"12"})],8,M))]))),128))],2)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),n.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":!n.isView}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.fileList,(l,r)=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.renderSlot(t.$slots,"file",{data:l},()=>[e.createElementVNode("span",null,e.toDisplayString(l.name),1),n.isView?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"k-file-icon-close",onClick:S=>k(r)},[e.createVNode(e.unref(s.Icon),{name:"close",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(n.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u683C\u5F0F\u6709\uFF1A"+e.toDisplayString(n.accept.join(","))+",\u6700\u591A\u4E0A\u4F20"+e.toDisplayString(n.limit)+"\u4E2A\u6587\u4EF6,"+e.toDisplayString(n.type=="file"?"\u5355\u4E2A\u6587\u4EF6":"\u5355\u5F20\u56FE\u7247")+"\u4E0D\u80FD\u5927\u4E8E"+e.toDisplayString(n.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(n.type=="file"?"\u6587\u4EF6":"\u56FE\u7247")+"\u6709\uFF1A",1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.errFiles,(l,r)=>(e.openBlock(),e.createElementBlock("span",{key:r},[r>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"},[m.value?(e.openBlock(),e.createElementBlock("div",P,[...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=G;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btt-ui",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [