@keyblade/pro-components 1.12.0-alpha.6 → 1.12.0-alpha.8
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.
- package/es/_virtual/_plugin-vue_export-helper.js +9 -0
- package/es/pro-image-upload/cropper.vue.d.ts +41 -0
- package/es/pro-image-upload/cropper.vue.js +7 -0
- package/es/pro-image-upload/cropper.vue2.js +211 -0
- package/es/pro-image-upload/cropper.vue3.js +1 -0
- package/es/pro-image-upload/image-upload.vue.d.ts +34 -34
- package/es/pro-image-upload/image-upload.vue.js +125 -105
- package/es/pro-image-upload/index.d.ts +115 -115
- package/es/pro-image-upload/index.js +8 -7
- package/es/pro-keep-alive-router-view/index.d.ts +1 -1
- package/es/pro-layout/index.d.ts +1 -1
- package/es/pro-menu/index.d.ts +1 -1
- package/es/pro-page-container/index.d.ts +1 -1
- package/es/pro-page-header/index.d.ts +4 -4
- package/es/pro-page-header/pro-page-header.vue.d.ts +1 -1
- package/es/pro-reuse-tabs/index.d.ts +1 -1
- package/es/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Message as
|
|
3
|
-
import { conclude as
|
|
1
|
+
import { defineComponent as ue, ref as m, computed as M, watch as G, resolveComponent as de, openBlock as J, createElementBlock as se, createVNode as ce, normalizeClass as fe, createBlock as ve, createCommentVNode as me } from "vue";
|
|
2
|
+
import { Message as x } from "@arco-design/web-vue";
|
|
3
|
+
import { conclude as L } from "vue-global-config";
|
|
4
4
|
import { EImageUploadInnerBeforeUploadStep as v } from "./types.js";
|
|
5
|
-
import { defaultImageUploadOptions as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { defaultImageUploadOptions as U } from "./constant.js";
|
|
6
|
+
import ge from "./cropper.vue.js";
|
|
7
|
+
import { defaultImageUploadCheckOptions as pe, defaultImageUploadCompressorOptions as Ie, defaultImageUploadCropOptions as he, oneTravelImageCheckAndTransform as xe, oneTravelImageCompressor as Ue } from "@keyblade/one-travel";
|
|
8
|
+
const Ce = "keyblade-pro-image-upload";
|
|
9
|
+
var K, X, Y;
|
|
10
|
+
const Oe = /* @__PURE__ */ ue({
|
|
10
11
|
__name: "image-upload",
|
|
11
12
|
props: {
|
|
12
13
|
action: {},
|
|
13
14
|
handlerResponse: {},
|
|
14
15
|
headers: {},
|
|
15
16
|
data: {},
|
|
16
|
-
name: { default: (
|
|
17
|
+
name: { default: (K = U) == null ? void 0 : K.name },
|
|
17
18
|
tip: {},
|
|
18
19
|
accept: { default: () => {
|
|
19
20
|
var B;
|
|
20
|
-
return ((B =
|
|
21
|
+
return ((B = U) == null ? void 0 : B.accept) || [];
|
|
21
22
|
} },
|
|
22
|
-
multiple: { type: Boolean, default:
|
|
23
|
-
singleLimit: { default:
|
|
23
|
+
multiple: { type: Boolean, default: U.multiple },
|
|
24
|
+
singleLimit: { default: U.singleLimit },
|
|
24
25
|
limit: {},
|
|
25
|
-
disabled: { type: Boolean, default: (
|
|
26
|
-
hideInnerBeforeUploadLoading: { type: Boolean, default: (
|
|
26
|
+
disabled: { type: Boolean, default: (X = U) == null ? void 0 : X.disabled },
|
|
27
|
+
hideInnerBeforeUploadLoading: { type: Boolean, default: (Y = U) == null ? void 0 : Y.hideInnerBeforeUploadLoading },
|
|
27
28
|
checkOptions: {},
|
|
28
29
|
compressorOptions: {},
|
|
29
30
|
cropOptions: {},
|
|
@@ -35,67 +36,75 @@ const Ee = /* @__PURE__ */ ne({
|
|
|
35
36
|
onInnerBeforeUploadEnd: {}
|
|
36
37
|
},
|
|
37
38
|
emits: ["cropperImgLoad"],
|
|
38
|
-
setup(B, { expose:
|
|
39
|
-
const e = B, i = defineModel({ required: !0 }),
|
|
39
|
+
setup(B, { expose: Z, emit: _ }) {
|
|
40
|
+
const e = B, i = defineModel({ required: !0 }), S = m(), O = m(), g = m(), p = m(
|
|
40
41
|
[]
|
|
41
|
-
), o = m(), c = m(), d = m(),
|
|
42
|
-
var t,
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
selectCount:
|
|
46
|
-
}), e != null && e.onBeforeUpload ? e == null ? void 0 : e.onBeforeUpload(a) : d.value && (e != null && e.singleLimit) && d.value.selectCount > (e == null ? void 0 : e.singleLimit) ? (d.value.handleIndex === void 0 ? (d.value.handleIndex = 0,
|
|
42
|
+
), o = m(), c = m(), d = m(), A = M(() => e.accept.map((a) => `.${a}`).join(",")), f = M(() => L([e.checkOptions, pe]) || {}), C = M(() => L([e.compressorOptions, Ie]) || {}), y = M(() => L([e.cropOptions, he]) || {}), R = (a) => {
|
|
43
|
+
var t, r, s, u;
|
|
44
|
+
const l = (u = (s = (r = (t = S.value) == null ? void 0 : t.$el) == null ? void 0 : r.querySelector) == null ? void 0 : s.call(r, "input")) == null ? void 0 : u.files;
|
|
45
|
+
return l && l.length > 0 && (d.value = {
|
|
46
|
+
selectCount: l.length
|
|
47
|
+
}), e != null && e.onBeforeUpload ? e == null ? void 0 : e.onBeforeUpload(a) : d.value && (e != null && e.singleLimit) && d.value.selectCount > (e == null ? void 0 : e.singleLimit) ? (d.value.handleIndex === void 0 ? (d.value.handleIndex = 0, x.error(`单次最多可选择${e == null ? void 0 : e.singleLimit}张图片`)) : d.value.handleIndex += 1, d.value.handleIndex === d.value.selectCount - 1 && (d.value = void 0), !1) : new Promise(async (E, w) => {
|
|
47
48
|
try {
|
|
48
|
-
E(await
|
|
49
|
+
E(await oe(a));
|
|
49
50
|
} catch {
|
|
50
51
|
w();
|
|
51
52
|
} finally {
|
|
52
|
-
|
|
53
|
+
$();
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
|
-
}, A = async (a) => {
|
|
56
|
-
const n = i.value.findIndex((t) => t.uid === a.uid);
|
|
57
|
-
return i.value.splice(n, 1), i.value = [...i.value], !1;
|
|
58
|
-
}, R = (a, n) => {
|
|
59
|
-
e != null && e.onExceed ? e == null || e.onExceed(a, n) : (U.error(`单次最多可选择${(e == null ? void 0 : e.limit) || 1}张图片`), i.value = a);
|
|
60
56
|
}, ee = async (a) => {
|
|
57
|
+
const l = i.value.findIndex((t) => t.uid === a.uid);
|
|
58
|
+
return i.value.splice(l, 1), i.value = [...i.value], !1;
|
|
59
|
+
}, ae = (a, l) => {
|
|
60
|
+
e != null && e.onExceed ? e == null || e.onExceed(a, l) : (x.error(`单次最多可选择${(e == null ? void 0 : e.limit) || 1}张图片`), i.value = a);
|
|
61
|
+
}, le = async (a) => {
|
|
61
62
|
if (e != null && e.onSuccess)
|
|
62
63
|
e == null || e.onSuccess(a);
|
|
63
64
|
else {
|
|
64
65
|
if (!(e != null && e.handlerResponse))
|
|
65
66
|
return;
|
|
66
|
-
const
|
|
67
|
-
|
|
67
|
+
const l = await e.handlerResponse(a.response), t = i.value.findIndex((r) => r.uid === a.uid);
|
|
68
|
+
l.success ? i.value[t] = {
|
|
68
69
|
...i.value[t],
|
|
69
|
-
...
|
|
70
|
+
...l
|
|
70
71
|
} : i.value.splice(t, 1);
|
|
71
72
|
}
|
|
72
|
-
},
|
|
73
|
+
}, ne = (a) => {
|
|
73
74
|
e != null && e.onError ? e == null || e.onError(a) : setTimeout(() => {
|
|
74
|
-
const
|
|
75
|
-
i.value.splice(
|
|
75
|
+
const l = i.value.findIndex((t) => t.uid === a.uid);
|
|
76
|
+
i.value.splice(l, 1);
|
|
76
77
|
});
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
}),
|
|
80
|
-
o.value === void 0 ? o.value = 0 : o.value + 1 >=
|
|
78
|
+
}, oe = (a) => new Promise((l, t) => {
|
|
79
|
+
p.value.push({ file: a, resolve: l, reject: t }), p.value.length === 1 && !o.value && $();
|
|
80
|
+
}), $ = () => {
|
|
81
|
+
o.value === void 0 ? o.value = 0 : o.value + 1 >= p.value.length ? (o.value = void 0, p.value = []) : o.value += 1;
|
|
82
|
+
}, te = () => {
|
|
83
|
+
var a;
|
|
84
|
+
(a = g.value) == null || a.reject();
|
|
85
|
+
}, ie = (a) => {
|
|
86
|
+
var l;
|
|
87
|
+
(l = g.value) == null || l.resolve(a);
|
|
88
|
+
}, re = (a) => {
|
|
89
|
+
_("cropperImgLoad", a);
|
|
81
90
|
};
|
|
82
|
-
|
|
83
|
-
var E, w,
|
|
84
|
-
if (o.value === void 0 ||
|
|
91
|
+
G(o, async () => {
|
|
92
|
+
var E, w, b, k, F, z, j, Q, H, W, N, P, T, q, V, D;
|
|
93
|
+
if (o.value === void 0 || p.value.length === 0)
|
|
85
94
|
return;
|
|
86
|
-
const a =
|
|
87
|
-
let s =
|
|
95
|
+
const a = p.value[o.value], { file: l, resolve: t, reject: r } = a;
|
|
96
|
+
let s = l.name, u = l;
|
|
88
97
|
if ((E = f.value) != null && E.enable) {
|
|
89
98
|
c.value = {
|
|
90
99
|
loading: !0,
|
|
91
100
|
text: `第${o.value + 1}张图片检测中,请稍等`
|
|
92
101
|
}, (w = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || w.call(
|
|
93
102
|
e,
|
|
94
|
-
|
|
103
|
+
l,
|
|
95
104
|
o.value,
|
|
96
105
|
v.check
|
|
97
106
|
);
|
|
98
|
-
const
|
|
107
|
+
const n = await xe(l, l.name, {
|
|
99
108
|
imageMaxSize: f.value.maxSize,
|
|
100
109
|
imageAllowedType: f.value.allowedType,
|
|
101
110
|
imageMinWidth: f.value.minWidth,
|
|
@@ -103,39 +112,39 @@ const Ee = /* @__PURE__ */ ne({
|
|
|
103
112
|
imageMaxWidth: f.value.maxWidth,
|
|
104
113
|
imageMaxHeight: f.value.maxHeight
|
|
105
114
|
});
|
|
106
|
-
if (c.value = void 0, (
|
|
115
|
+
if (c.value = void 0, (b = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || b.call(
|
|
107
116
|
e,
|
|
108
|
-
|
|
117
|
+
l,
|
|
109
118
|
o.value,
|
|
110
119
|
v.check,
|
|
111
120
|
{
|
|
112
|
-
success:
|
|
113
|
-
error:
|
|
114
|
-
errorMessage:
|
|
121
|
+
success: n.success,
|
|
122
|
+
error: n == null ? void 0 : n.error,
|
|
123
|
+
errorMessage: n == null ? void 0 : n.errorMessage
|
|
115
124
|
}
|
|
116
|
-
), !
|
|
117
|
-
return (
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
type:
|
|
125
|
+
), !n.success)
|
|
126
|
+
return (k = f.value) != null && k.showErrorMessage && x.error((n == null ? void 0 : n.errorMessage) || "图片校验及转换失败"), r();
|
|
127
|
+
if (n != null && n.hasTransform) {
|
|
128
|
+
const h = s == null ? void 0 : s.split(".");
|
|
129
|
+
h.pop(), s = `${h.join(",")}.jpg`, u = new File([n.file], s, {
|
|
130
|
+
type: n.file.type
|
|
122
131
|
});
|
|
123
132
|
} else
|
|
124
|
-
|
|
133
|
+
u = n.file;
|
|
125
134
|
}
|
|
126
135
|
if ((F = y.value) != null && F.enable) {
|
|
127
136
|
(z = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || z.call(
|
|
128
137
|
e,
|
|
129
|
-
|
|
138
|
+
l,
|
|
130
139
|
o.value,
|
|
131
140
|
v.crop
|
|
132
141
|
);
|
|
133
142
|
try {
|
|
134
|
-
(j = y.value) != null && j.customCrop ?
|
|
135
|
-
|
|
136
|
-
}), (
|
|
143
|
+
(j = y.value) != null && j.customCrop ? u = await y.value.customCrop(u) : u = await new Promise((n, h) => {
|
|
144
|
+
g.value = { file: u, resolve: n, reject: h };
|
|
145
|
+
}), (Q = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || Q.call(
|
|
137
146
|
e,
|
|
138
|
-
|
|
147
|
+
l,
|
|
139
148
|
o.value,
|
|
140
149
|
v.crop,
|
|
141
150
|
{
|
|
@@ -143,9 +152,9 @@ const Ee = /* @__PURE__ */ ne({
|
|
|
143
152
|
}
|
|
144
153
|
);
|
|
145
154
|
} catch {
|
|
146
|
-
return (
|
|
155
|
+
return (H = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || H.call(
|
|
147
156
|
e,
|
|
148
|
-
|
|
157
|
+
l,
|
|
149
158
|
o.value,
|
|
150
159
|
v.crop,
|
|
151
160
|
{
|
|
@@ -155,98 +164,109 @@ const Ee = /* @__PURE__ */ ne({
|
|
|
155
164
|
},
|
|
156
165
|
errorMessage: "图片剪裁失败"
|
|
157
166
|
}
|
|
158
|
-
), (
|
|
167
|
+
), (W = y.value) != null && W.showErrorMessage && x.error("图片剪裁失败"), r();
|
|
159
168
|
} finally {
|
|
160
|
-
|
|
169
|
+
g.value = void 0;
|
|
161
170
|
}
|
|
162
171
|
}
|
|
163
|
-
if ((
|
|
172
|
+
if ((N = C.value) != null && N.enable) {
|
|
164
173
|
c.value = {
|
|
165
174
|
loading: !0,
|
|
166
175
|
text: `第${o.value + 1}张图片处理中,请稍等`
|
|
167
176
|
}, (P = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || P.call(
|
|
168
177
|
e,
|
|
169
|
-
|
|
178
|
+
l,
|
|
170
179
|
o.value,
|
|
171
180
|
v.compress
|
|
172
181
|
);
|
|
173
|
-
const
|
|
174
|
-
maxSize:
|
|
175
|
-
size:
|
|
176
|
-
excludeAllowedTypes: (T =
|
|
182
|
+
const n = await Ue(u, {
|
|
183
|
+
maxSize: C.value.maxSize,
|
|
184
|
+
size: C.value.size,
|
|
185
|
+
excludeAllowedTypes: (T = C.value.excludeAllowedTypes) == null ? void 0 : T.map((h) => `image/${h}`)
|
|
177
186
|
});
|
|
178
187
|
if (c.value = void 0, (q = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || q.call(
|
|
179
188
|
e,
|
|
180
|
-
|
|
189
|
+
l,
|
|
181
190
|
o.value,
|
|
182
191
|
v.compress,
|
|
183
192
|
{
|
|
184
|
-
success:
|
|
193
|
+
success: n.success,
|
|
185
194
|
error: {
|
|
186
195
|
compress: !0
|
|
187
196
|
},
|
|
188
|
-
errorMessage:
|
|
197
|
+
errorMessage: n == null ? void 0 : n.errorMessage
|
|
189
198
|
}
|
|
190
|
-
), !
|
|
191
|
-
return (
|
|
192
|
-
|
|
193
|
-
type:
|
|
199
|
+
), !n.success)
|
|
200
|
+
return (V = C.value) != null && V.showErrorMessage && x.error((n == null ? void 0 : n.errorMessage) || "图片压缩失败"), r();
|
|
201
|
+
u = new File([n.file], s, {
|
|
202
|
+
type: n.file.type
|
|
194
203
|
});
|
|
195
204
|
}
|
|
196
|
-
c.value = void 0, (
|
|
205
|
+
c.value = void 0, (D = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || D.call(
|
|
197
206
|
e,
|
|
198
|
-
|
|
207
|
+
l,
|
|
199
208
|
o.value,
|
|
200
209
|
v.all,
|
|
201
210
|
{
|
|
202
211
|
success: !0
|
|
203
212
|
}
|
|
204
|
-
), t(
|
|
213
|
+
), t(u);
|
|
205
214
|
});
|
|
206
|
-
let
|
|
207
|
-
return
|
|
215
|
+
let I;
|
|
216
|
+
return G(
|
|
208
217
|
() => c.value,
|
|
209
218
|
() => {
|
|
210
219
|
var a;
|
|
211
|
-
c.value ?
|
|
220
|
+
c.value ? I = x.loading({
|
|
212
221
|
content: c.value.text,
|
|
213
222
|
id: "image-upload-id",
|
|
214
223
|
duration: 0
|
|
215
|
-
}) : (a =
|
|
224
|
+
}) : (a = I == null ? void 0 : I.close) == null || a.call(I);
|
|
216
225
|
}
|
|
217
|
-
),
|
|
218
|
-
uploadInsRef:
|
|
219
|
-
cropperInsRef:
|
|
220
|
-
}), (a,
|
|
221
|
-
const t =
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
class:
|
|
226
|
+
), Z({
|
|
227
|
+
uploadInsRef: S,
|
|
228
|
+
cropperInsRef: O
|
|
229
|
+
}), (a, l) => {
|
|
230
|
+
const t = de("a-upload");
|
|
231
|
+
return J(), se("div", null, [
|
|
232
|
+
ce(t, {
|
|
233
|
+
class: fe([`${Ce}-upload`]),
|
|
225
234
|
ref_key: "uploadInsRef",
|
|
226
|
-
ref:
|
|
235
|
+
ref: S,
|
|
227
236
|
"list-type": "picture-card",
|
|
228
237
|
tip: a.tip || "上传",
|
|
229
238
|
"image-preview": "",
|
|
230
239
|
"file-list": i.value,
|
|
231
|
-
"onUpdate:fileList":
|
|
240
|
+
"onUpdate:fileList": l[0] || (l[0] = (r) => i.value = r),
|
|
232
241
|
action: a.action,
|
|
233
242
|
headers: a.headers,
|
|
234
243
|
data: a.data,
|
|
235
244
|
name: a.name,
|
|
236
|
-
accept:
|
|
245
|
+
accept: A.value,
|
|
237
246
|
multiple: a.multiple,
|
|
238
247
|
limit: a.limit,
|
|
239
248
|
disabled: a.disabled,
|
|
240
|
-
"on-before-upload":
|
|
241
|
-
"on-before-remove":
|
|
242
|
-
onExceedLimit:
|
|
243
|
-
onSuccess:
|
|
244
|
-
onError:
|
|
245
|
-
}, null, 8, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"])
|
|
249
|
+
"on-before-upload": R,
|
|
250
|
+
"on-before-remove": ee,
|
|
251
|
+
onExceedLimit: ae,
|
|
252
|
+
onSuccess: le,
|
|
253
|
+
onError: ne
|
|
254
|
+
}, null, 8, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"]),
|
|
255
|
+
g.value && o.value !== void 0 ? (J(), ve(ge, {
|
|
256
|
+
key: 0,
|
|
257
|
+
ref_key: "cropperInsRef",
|
|
258
|
+
ref: O,
|
|
259
|
+
file: g.value.file,
|
|
260
|
+
index: o.value,
|
|
261
|
+
options: y.value,
|
|
262
|
+
onCancel: te,
|
|
263
|
+
onConfirm: ie,
|
|
264
|
+
onImgLoad: re
|
|
265
|
+
}, null, 8, ["file", "index", "options"])) : me("", !0)
|
|
246
266
|
]);
|
|
247
267
|
};
|
|
248
268
|
}
|
|
249
269
|
});
|
|
250
270
|
export {
|
|
251
|
-
|
|
271
|
+
Oe as default
|
|
252
272
|
};
|