@dazhicheng/ui 1.6.29 → 1.6.30
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,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as fe, mergeModels as B, useModel as me, useSlots as we, ref as
|
|
1
|
+
import { defineComponent as fe, mergeModels as B, useModel as me, useSlots as we, ref as $, computed as m, createBlock as ve, openBlock as _e, createVNode as n, mergeProps as ye, createTextVNode as w } from "vue";
|
|
2
2
|
import ge from "../../../assets/svg/exportSvg.svg.js";
|
|
3
3
|
import M from "../../../assets/svg/fileSvg.svg.js";
|
|
4
|
-
import { TtButton as
|
|
4
|
+
import { TtButton as k } from "../../tt-button/index.js";
|
|
5
5
|
import { TtIcon as b } from "../../tt-icon/index.js";
|
|
6
6
|
import "../../tt-modal/index.js";
|
|
7
7
|
import "../../../node_modules/.pnpm/vue-types@5.1.3_vue@3.5.21_typescript@5.9.3_/node_modules/vue-types/shim/index.modern.js";
|
|
8
8
|
import { useDesign as he } from "../../../packages/hooks/src/useDesign.js";
|
|
9
9
|
import "axios";
|
|
10
|
-
import { ElMessage as f, ElImageViewer as
|
|
11
|
-
import { isString as
|
|
10
|
+
import { ElMessage as f, ElImageViewer as Ue, ElUpload as $e } from "element-plus";
|
|
11
|
+
import { isString as ke, isNumber as be } from "../../../packages/utils/src/is.js";
|
|
12
12
|
import "dayjs";
|
|
13
13
|
import "numeral";
|
|
14
14
|
import "xe-utils";
|
|
@@ -41,13 +41,13 @@ const ao = /* @__PURE__ */ fe({
|
|
|
41
41
|
expose: P,
|
|
42
42
|
emit: V
|
|
43
43
|
}) {
|
|
44
|
-
const N = ["modal", "modelValue", "ossType", "uploadOssApi", "uploadTip", "maxSize", "showFileList", "showUploadArea", "showTemplateDownload", "templateText", "showPreview", "showDownload", "showDelete", "gridThreshold", "gridColumns", "showCount", "uploadOssViewApi", "beforeUpload", "onError"],
|
|
45
|
-
function
|
|
44
|
+
const N = ["modal", "modelValue", "ossType", "uploadOssApi", "uploadTip", "maxSize", "showFileList", "showUploadArea", "showTemplateDownload", "templateText", "showPreview", "showDownload", "showDelete", "gridThreshold", "gridColumns", "showCount", "uploadOssViewApi", "beforeUpload", "onError"], D = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg"]);
|
|
45
|
+
function I(e) {
|
|
46
46
|
var t;
|
|
47
47
|
const o = ((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "";
|
|
48
|
-
return
|
|
48
|
+
return D.has(o);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function K(e, o, t) {
|
|
51
51
|
var r;
|
|
52
52
|
if (!(t != null && t.trim())) return !0;
|
|
53
53
|
const l = e.includes(".") ? ((r = e.split(".").pop()) == null ? void 0 : r.toLowerCase()) ?? "" : "";
|
|
@@ -55,7 +55,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
55
55
|
}
|
|
56
56
|
const a = S, p = V, u = me(S, "modelValue"), d = we(), {
|
|
57
57
|
prefixCls: i
|
|
58
|
-
} = he("upload"), C =
|
|
58
|
+
} = he("upload"), C = $(), h = $(!1), x = $([]), [j, v] = xe({
|
|
59
59
|
onOk() {
|
|
60
60
|
p("ok", u.value);
|
|
61
61
|
},
|
|
@@ -74,7 +74,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
74
74
|
closeModal: v.closeModal,
|
|
75
75
|
getFileList: W
|
|
76
76
|
});
|
|
77
|
-
const
|
|
77
|
+
const U = m(() => u.value.length > a.gridThreshold), _ = m(() => a.limit ?? 0), y = m(() => a.uploadOssApi ?? T.uploadOssApi), G = m(() => a.uploadOssViewApi ?? T.uploadOssViewApi ?? Ce);
|
|
78
78
|
async function q(e, o) {
|
|
79
79
|
const l = (a.ossDir || o.dir || "notice").replace(/\/+$/, ""), s = l ? `${l}/${Date.now()}_${e.name}` : `${Date.now()}_${e.name}`, r = new FormData();
|
|
80
80
|
r.append("key", s), r.append("policy", o.policy), r.append("x-oss-signature-version", o.version), r.append("x-oss-signature", o.signature), r.append("x-oss-credential", o.x_oss_credential), r.append("x-oss-date", o.x_oss_date), r.append("x-oss-security-token", o.security_token), o.callback && r.append("callback", o.callback), r.append("success_action_status", "200"), r.append("file", e);
|
|
@@ -88,7 +88,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
88
88
|
}
|
|
89
89
|
async function H(e, o) {
|
|
90
90
|
const l = (a.ossDir || o.dir || "notice").replace(/\/+$/, ""), s = l ? `${l}/${Date.now()}_${e.name}` : `${Date.now()}_${e.name}`, r = new FormData();
|
|
91
|
-
r.append("key", s), r.append("policy", o.policy), r.append("AccessKeyId", o.accessKeyId), r.append("signature", o.signature), o.security_token && r.append("x-obs-security-token", o.security_token), o.callbackUrl && r.append("callbackUrl", o.callbackUrl), o.callbackBody && r.append("callbackBody", o.callbackBody), o.callbackBodyType && r.append("callbackBodyType", o.callbackBodyType),
|
|
91
|
+
r.append("key", s), r.append("policy", o.policy), r.append("AccessKeyId", o.accessKeyId), r.append("signature", o.signature), o.security_token && r.append("x-obs-security-token", o.security_token), o.callbackUrl && r.append("callbackUrl", o.callbackUrl), o.callbackBody && r.append("callbackBody", o.callbackBody), o.callbackBodyType && r.append("callbackBodyType", o.callbackBodyType), r.append("success_action_status", "200"), r.append("file", e);
|
|
92
92
|
const c = await fetch(o.host, {
|
|
93
93
|
method: "POST",
|
|
94
94
|
body: r
|
|
@@ -160,9 +160,9 @@ const ao = /* @__PURE__ */ fe({
|
|
|
160
160
|
httpRequest: y.value ? Q : J
|
|
161
161
|
}));
|
|
162
162
|
function oe(e) {
|
|
163
|
-
if (!
|
|
163
|
+
if (!K(e.name, e.type, a.accept))
|
|
164
164
|
return f.warning(`文件格式不支持,仅支持:${a.accept}`), !1;
|
|
165
|
-
const o = u.value.map((t) =>
|
|
165
|
+
const o = u.value.map((t) => ke(t.fileSize) || be(t.fileSize) ? +t.fileSize : 0).reduce((t, l) => t + l, 0);
|
|
166
166
|
return a.maxSize && (e.size + o) / 1024 / 1024 > a.maxSize ? (f.warning(`文件大小不能超过 ${a.maxSize}MB`), !1) : _.value > 0 && u.value.length >= _.value ? (f.warning("已超过上传数量"), !1) : z(a.beforeUpload) ? a.beforeUpload(e) : !0;
|
|
167
167
|
}
|
|
168
168
|
function te() {
|
|
@@ -200,7 +200,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
200
200
|
async function re(e) {
|
|
201
201
|
p("preview", e);
|
|
202
202
|
let o = await E(e);
|
|
203
|
-
y.value || (o = URL.createObjectURL(e.file)), o && (
|
|
203
|
+
y.value || (o = URL.createObjectURL(e.file)), o && (I(e.fileName) ? (x.value = [o], h.value = !0) : window.open(o, "_blank"));
|
|
204
204
|
}
|
|
205
205
|
async function ne(e) {
|
|
206
206
|
let o = !1;
|
|
@@ -213,7 +213,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
213
213
|
}
|
|
214
214
|
const ie = () => a.showUploadArea ? n("div", {
|
|
215
215
|
class: `${i}-area`
|
|
216
|
-
}, [n(
|
|
216
|
+
}, [n($e, ye({
|
|
217
217
|
ref: C
|
|
218
218
|
}, ee.value), {
|
|
219
219
|
default: () => {
|
|
@@ -240,19 +240,19 @@ const ao = /* @__PURE__ */ fe({
|
|
|
240
240
|
index: o
|
|
241
241
|
}) : n("div", {
|
|
242
242
|
class: `${i}-file__actions`
|
|
243
|
-
}, [a.showPreview && n(
|
|
243
|
+
}, [a.showPreview && n(k, {
|
|
244
244
|
type: "primary",
|
|
245
245
|
link: !0,
|
|
246
246
|
onClick: () => re(e)
|
|
247
247
|
}, {
|
|
248
248
|
default: () => [w("查看")]
|
|
249
|
-
}), a.showDownload && n(
|
|
249
|
+
}), a.showDownload && n(k, {
|
|
250
250
|
type: "primary",
|
|
251
251
|
link: !0,
|
|
252
252
|
onClick: () => ne(e)
|
|
253
253
|
}, {
|
|
254
254
|
default: () => [w("下载")]
|
|
255
|
-
}), a.showDelete && !a.disabled && n(
|
|
255
|
+
}), a.showDelete && !a.disabled && n(k, {
|
|
256
256
|
type: "danger",
|
|
257
257
|
link: !0,
|
|
258
258
|
onClick: () => le(e)
|
|
@@ -297,9 +297,9 @@ const ao = /* @__PURE__ */ fe({
|
|
|
297
297
|
}, [A(e, o)])]), ue = (e, o) => d.fileItem ? d.fileItem({
|
|
298
298
|
file: e,
|
|
299
299
|
index: o
|
|
300
|
-
}) :
|
|
300
|
+
}) : U.value ? se(e, o) : ce(e, o), de = () => {
|
|
301
301
|
if (!a.showFileList || u.value.length === 0) return null;
|
|
302
|
-
const e = u.value.map((l, s) => ue(l, s)), o =
|
|
302
|
+
const e = u.value.map((l, s) => ue(l, s)), o = U.value ? `${i}-filelist__grid` : `${i}-filelist__list`, t = U.value ? {
|
|
303
303
|
gridTemplateColumns: `repeat(${a.gridColumns}, 1fr)`
|
|
304
304
|
} : void 0;
|
|
305
305
|
return n("div", {
|
|
@@ -318,7 +318,7 @@ const ao = /* @__PURE__ */ fe({
|
|
|
318
318
|
var e;
|
|
319
319
|
return n("div", {
|
|
320
320
|
class: i
|
|
321
|
-
}, [ie(), de(), (e = d.footer) == null ? void 0 : e.call(d), h.value && n(
|
|
321
|
+
}, [ie(), de(), (e = d.footer) == null ? void 0 : e.call(d), h.value && n(Ue, {
|
|
322
322
|
urlList: x.value,
|
|
323
323
|
hideOnClickModal: !0,
|
|
324
324
|
teleported: !0,
|