@orchidui/core 1.106.0 → 1.107.0
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,24 +1,26 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
},
|
|
6
|
-
const
|
|
7
|
-
const e = [...
|
|
8
|
-
const s = !
|
|
9
|
-
if (s || n("fileExist"),
|
|
10
|
-
const i =
|
|
1
|
+
import { ref as v } from "vue";
|
|
2
|
+
const g = (d, n) => {
|
|
3
|
+
const f = n.split(","), c = d.name.split(".").pop().toLowerCase();
|
|
4
|
+
return f.find((l) => l.includes(c));
|
|
5
|
+
}, z = (d, n, f, c = !1) => {
|
|
6
|
+
const l = v([]), p = v(!1), E = (t, o = !1) => {
|
|
7
|
+
const e = [...t.target.files].filter((a) => {
|
|
8
|
+
const s = !l.value.some((i) => i.fileName === a.name);
|
|
9
|
+
if (s || n("fileExist"), c) {
|
|
10
|
+
const i = g(a, f);
|
|
11
11
|
return i || n("invalidFileType"), s && i;
|
|
12
12
|
} else
|
|
13
13
|
return s;
|
|
14
|
-
});
|
|
15
|
-
if (
|
|
14
|
+
}), u = t.target;
|
|
15
|
+
if (u && setTimeout(() => {
|
|
16
|
+
u.value = "";
|
|
17
|
+
}), p.value = e.reduce((a, s) => a + s.size, 0) > d * 1024 * 1024, p.value) {
|
|
16
18
|
n("onExceedMaxFileSize", e);
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
for (let
|
|
20
|
-
const s = e[
|
|
21
|
-
new FormData().append("file", s),
|
|
21
|
+
for (let a = 0; a < e.length; a++) {
|
|
22
|
+
const s = e[a], i = new FileReader();
|
|
23
|
+
new FormData().append("file", s), l.value.unshift({
|
|
22
24
|
file: s,
|
|
23
25
|
fileName: s.name,
|
|
24
26
|
link: s.link,
|
|
@@ -27,38 +29,38 @@ const E = (u, n) => {
|
|
|
27
29
|
totalSize: 0,
|
|
28
30
|
isLoaded: !1,
|
|
29
31
|
extension: s.name.split(".").at(-1) || "png"
|
|
30
|
-
}), n("update:modelValue",
|
|
32
|
+
}), n("update:modelValue", o ? l.value[0] : l.value), s && (F(i, a), i.readAsDataURL(s));
|
|
31
33
|
}
|
|
32
|
-
}, r = (
|
|
33
|
-
if (!
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
34
|
+
}, r = (t, o, e) => {
|
|
35
|
+
if (!t.type) return;
|
|
36
|
+
const u = () => {
|
|
37
|
+
l.value[e].totalSize = t.total;
|
|
38
|
+
}, a = () => {
|
|
39
|
+
l.value[e].fileUrl = o.result, l.value[e].isLoaded = !0;
|
|
38
40
|
};
|
|
39
41
|
({
|
|
40
|
-
loadstart:
|
|
41
|
-
loadend:
|
|
42
|
-
load:
|
|
42
|
+
loadstart: u,
|
|
43
|
+
loadend: a,
|
|
44
|
+
load: a,
|
|
43
45
|
progress: () => {
|
|
44
|
-
|
|
45
|
-
(
|
|
46
|
+
l.value[e].progress = Number(
|
|
47
|
+
(t.loaded / l.value[e].totalSize * 100).toFixed(2)
|
|
46
48
|
);
|
|
47
49
|
}
|
|
48
|
-
})[
|
|
49
|
-
}, F = (
|
|
50
|
-
|
|
50
|
+
})[t.type]();
|
|
51
|
+
}, F = (t, o) => {
|
|
52
|
+
t.addEventListener("loadstart", (e) => r(e, t, o)), t.addEventListener("load", (e) => r(e, t, o)), t.addEventListener("loadend", (e) => r(e, t, o)), t.addEventListener("progress", (e) => r(e, t, o)), t.addEventListener("error", (e) => r(e, t, o)), t.addEventListener("abort", (e) => r(e, t, o));
|
|
51
53
|
};
|
|
52
54
|
return {
|
|
53
|
-
isErrorMaxSize:
|
|
54
|
-
currentFiles:
|
|
55
|
-
onChangeFile:
|
|
56
|
-
onDeleteFile: (
|
|
57
|
-
let
|
|
58
|
-
|
|
55
|
+
isErrorMaxSize: p,
|
|
56
|
+
currentFiles: l,
|
|
57
|
+
onChangeFile: E,
|
|
58
|
+
onDeleteFile: (t) => {
|
|
59
|
+
let o = l.value.find((e, u) => u === t);
|
|
60
|
+
l.value = l.value.filter((e) => e !== o), n("onRemoveFile", o), n("update:modelValue", l.value.length > 0 ? l.value : null);
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
63
|
};
|
|
62
64
|
export {
|
|
63
|
-
|
|
65
|
+
z as useUploadFileProgress
|
|
64
66
|
};
|