@keyblade/pro-components 1.12.7 → 1.12.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as se, mergeModels as G, useModel as ce, ref as m, computed as M, watch as J, resolveComponent as fe, openBlock as K, createElementBlock as ve, createVNode as me, normalizeClass as ge, createBlock as pe, createCommentVNode as
|
|
1
|
+
import { defineComponent as se, mergeModels as G, useModel as ce, ref as m, computed as M, watch as J, resolveComponent as fe, openBlock as K, createElementBlock as ve, createVNode as me, normalizeClass as ge, createBlock as pe, createCommentVNode as he } from "vue";
|
|
2
2
|
import { Message as g } from "@arco-design/web-vue";
|
|
3
3
|
import { conclude as L } from "vue-global-config";
|
|
4
4
|
import { EImageUploadInnerBeforeUploadStep as v } from "./types.js";
|
|
5
5
|
import { defaultImageUploadOptions as U } from "./constant.js";
|
|
6
|
-
import
|
|
6
|
+
import Ie from "./cropper.vue.js";
|
|
7
7
|
import { defaultImageUploadCheckOptions as xe, defaultImageUploadCompressorOptions as Ue, defaultImageUploadCropOptions as Ce, oneTravelImageCheckAndTransform as ye, oneTravelImageCompressor as Be } from "@keyblade/one-travel";
|
|
8
8
|
const Ee = "keyblade-pro-image-upload";
|
|
9
9
|
var X, Y, Z;
|
|
@@ -40,14 +40,14 @@ const Fe = /* @__PURE__ */ se({
|
|
|
40
40
|
}),
|
|
41
41
|
emits: /* @__PURE__ */ G(["cropperImgLoad"], ["update:modelValue"]),
|
|
42
42
|
setup(C, { expose: A, emit: R }) {
|
|
43
|
-
const i = ce(C, "modelValue"), e = C, _ = R, S = m(), O = m(), p = m(),
|
|
43
|
+
const i = ce(C, "modelValue"), e = C, _ = R, S = m(), O = m(), p = m(), h = m(
|
|
44
44
|
[]
|
|
45
|
-
), n = m(), c = m(),
|
|
46
|
-
var t, r,
|
|
47
|
-
const l = (u = (
|
|
48
|
-
return l && l.length > 0 && (
|
|
45
|
+
), n = m(), c = m(), s = m(), ee = M(() => e.accept.map((a) => `.${a}`).join(",")), f = M(() => L([e.checkOptions, xe]) || {}), y = M(() => L([e.compressorOptions, Ue]) || {}), B = M(() => L([e.cropOptions, Ce]) || {}), ae = (a) => {
|
|
46
|
+
var t, r, d, u;
|
|
47
|
+
const l = (u = (d = (r = (t = S.value) == null ? void 0 : t.$el) == null ? void 0 : r.querySelector) == null ? void 0 : d.call(r, "input")) == null ? void 0 : u.files;
|
|
48
|
+
return l && l.length > 0 && (s.value = {
|
|
49
49
|
selectCount: l.length
|
|
50
|
-
}), e != null && e.onBeforeUpload ? e == null ? void 0 : e.onBeforeUpload(a) :
|
|
50
|
+
}), e != null && e.onBeforeUpload ? e == null ? void 0 : e.onBeforeUpload(a) : s.value && (e != null && e.singleLimit) && s.value.selectCount > (e == null ? void 0 : e.singleLimit) ? (s.value.handleIndex === void 0 ? (s.value.handleIndex = 0, g.clear(), g.error(`单次最多可选择${e == null ? void 0 : e.singleLimit}张图片`)) : s.value.handleIndex += 1, s.value.handleIndex === s.value.selectCount - 1 && (s.value = void 0), !1) : new Promise(async (E, w) => {
|
|
51
51
|
try {
|
|
52
52
|
E(await ie(a));
|
|
53
53
|
} catch {
|
|
@@ -79,9 +79,9 @@ const Fe = /* @__PURE__ */ se({
|
|
|
79
79
|
i.value.splice(l, 1);
|
|
80
80
|
});
|
|
81
81
|
}, ie = (a) => new Promise((l, t) => {
|
|
82
|
-
|
|
82
|
+
h.value.push({ file: a, resolve: l, reject: t }), h.value.length === 1 && !n.value && $();
|
|
83
83
|
}), $ = () => {
|
|
84
|
-
n.value === void 0 ? n.value = 0 : n.value + 1 >=
|
|
84
|
+
n.value === void 0 ? n.value = 0 : n.value + 1 >= h.value.length ? (n.value = void 0, h.value = []) : n.value += 1;
|
|
85
85
|
}, re = () => {
|
|
86
86
|
var a;
|
|
87
87
|
(a = p.value) == null || a.reject();
|
|
@@ -92,11 +92,11 @@ const Fe = /* @__PURE__ */ se({
|
|
|
92
92
|
_("cropperImgLoad", a);
|
|
93
93
|
};
|
|
94
94
|
J(n, async () => {
|
|
95
|
-
var E, w, b, k, F, z, j, Q, V,
|
|
96
|
-
if (n.value === void 0 ||
|
|
95
|
+
var E, w, b, k, F, z, j, Q, V, W, H, N, P, T, q, D;
|
|
96
|
+
if (n.value === void 0 || h.value.length === 0)
|
|
97
97
|
return;
|
|
98
|
-
const a =
|
|
99
|
-
let
|
|
98
|
+
const a = h.value[n.value], { file: l, resolve: t, reject: r } = a;
|
|
99
|
+
let d = l.name, u = l;
|
|
100
100
|
if ((E = f.value) != null && E.enable) {
|
|
101
101
|
c.value = {
|
|
102
102
|
loading: !0,
|
|
@@ -128,14 +128,14 @@ const Fe = /* @__PURE__ */ se({
|
|
|
128
128
|
), !o.success)
|
|
129
129
|
return (k = f.value) != null && k.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片校验及转换失败"), r();
|
|
130
130
|
if (o != null && o.hasTransform) {
|
|
131
|
-
const x =
|
|
132
|
-
x.pop(),
|
|
131
|
+
const x = d == null ? void 0 : d.split(".");
|
|
132
|
+
x.pop(), d = `${x.join(",")}.jpg`, u = new File([o.file], d, {
|
|
133
133
|
type: o.file.type
|
|
134
134
|
});
|
|
135
135
|
} else
|
|
136
136
|
u = o.file;
|
|
137
137
|
}
|
|
138
|
-
if ((F = B.value) != null && F.enable) {
|
|
138
|
+
if ((F = B.value) != null && F.enable && !d.endsWith(".gif")) {
|
|
139
139
|
(z = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || z.call(
|
|
140
140
|
e,
|
|
141
141
|
l,
|
|
@@ -167,12 +167,12 @@ const Fe = /* @__PURE__ */ se({
|
|
|
167
167
|
},
|
|
168
168
|
errorMessage: "图片剪裁失败"
|
|
169
169
|
}
|
|
170
|
-
), (
|
|
170
|
+
), (W = B.value) != null && W.showErrorMessage && g.error("图片剪裁失败"), r();
|
|
171
171
|
} finally {
|
|
172
172
|
p.value = void 0;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
if ((
|
|
175
|
+
if ((H = y.value) != null && H.enable) {
|
|
176
176
|
c.value = {
|
|
177
177
|
loading: !0,
|
|
178
178
|
text: `第${n.value + 1}张图片处理中,请稍等`
|
|
@@ -201,7 +201,7 @@ const Fe = /* @__PURE__ */ se({
|
|
|
201
201
|
}
|
|
202
202
|
), !o.success)
|
|
203
203
|
return (q = y.value) != null && q.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片压缩失败"), r();
|
|
204
|
-
u = new File([o.file],
|
|
204
|
+
u = new File([o.file], d, {
|
|
205
205
|
type: o.file.type
|
|
206
206
|
});
|
|
207
207
|
}
|
|
@@ -215,16 +215,16 @@ const Fe = /* @__PURE__ */ se({
|
|
|
215
215
|
}
|
|
216
216
|
), t(u);
|
|
217
217
|
});
|
|
218
|
-
let
|
|
218
|
+
let I;
|
|
219
219
|
return J(
|
|
220
220
|
() => c.value,
|
|
221
221
|
() => {
|
|
222
222
|
var a;
|
|
223
|
-
c.value ?
|
|
223
|
+
c.value ? I = g.loading({
|
|
224
224
|
content: c.value.text,
|
|
225
225
|
id: "image-upload-id",
|
|
226
226
|
duration: 0
|
|
227
|
-
}) : (a =
|
|
227
|
+
}) : (a = I == null ? void 0 : I.close) == null || a.call(I);
|
|
228
228
|
}
|
|
229
229
|
), A({
|
|
230
230
|
uploadInsRef: S,
|
|
@@ -255,7 +255,7 @@ const Fe = /* @__PURE__ */ se({
|
|
|
255
255
|
onSuccess: ne,
|
|
256
256
|
onError: te
|
|
257
257
|
}, null, 8, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"]),
|
|
258
|
-
p.value && n.value !== void 0 ? (K(), pe(
|
|
258
|
+
p.value && n.value !== void 0 ? (K(), pe(Ie, {
|
|
259
259
|
key: 0,
|
|
260
260
|
ref_key: "cropperInsRef",
|
|
261
261
|
ref: O,
|
|
@@ -265,7 +265,7 @@ const Fe = /* @__PURE__ */ se({
|
|
|
265
265
|
onCancel: re,
|
|
266
266
|
onConfirm: ue,
|
|
267
267
|
onImgLoad: de
|
|
268
|
-
}, null, 8, ["file", "index", "options"])) :
|
|
268
|
+
}, null, 8, ["file", "index", "options"])) : he("", !0)
|
|
269
269
|
]);
|
|
270
270
|
};
|
|
271
271
|
}
|