@dazhicheng/ui 1.6.27 → 1.6.29
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/dist/api/oss.d.ts +10 -0
- package/dist/api/oss.js +26 -0
- package/dist/components/tt-upload/index.d.ts +38 -23
- package/dist/components/tt-upload/src/TtUpload.vue.d.ts +19 -10
- package/dist/components/tt-upload/src/TtUpload.vue.js +185 -169
- package/dist/components/tt-upload/src/typing.d.ts +33 -2
- package/dist/components/tt-upload/src/typing.js +5 -0
- package/dist/components/types.d.ts +6 -4
- package/dist/hooks/useFormSchemasLink.d.ts +46 -8
- package/dist/hooks/useFormSchemasLink.js +269 -198
- package/dist/hooks/useScreenshotOss.d.ts +5 -3
- package/dist/hooks/useScreenshotOss.js +57 -48
- package/dist/hooks/useSetup.js +16 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +102 -98
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as fe, mergeModels as B, useModel as me, useSlots as we, ref as U, computed as m, createBlock as ve, openBlock as _e, createVNode as n, mergeProps as ye, createTextVNode as w } from "vue";
|
|
2
|
+
import ge from "../../../assets/svg/exportSvg.svg.js";
|
|
3
|
+
import M from "../../../assets/svg/fileSvg.svg.js";
|
|
4
4
|
import { TtButton as $ } from "../../tt-button/index.js";
|
|
5
|
-
import { TtIcon as
|
|
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
|
-
import { useDesign as
|
|
8
|
+
import { useDesign as he } from "../../../packages/hooks/src/useDesign.js";
|
|
9
9
|
import "axios";
|
|
10
|
-
import { ElMessage as
|
|
11
|
-
import { isString as
|
|
10
|
+
import { ElMessage as f, ElImageViewer as ke, ElUpload as Ue } from "element-plus";
|
|
11
|
+
import { isString as $e, isNumber as be } from "../../../packages/utils/src/is.js";
|
|
12
12
|
import "dayjs";
|
|
13
13
|
import "numeral";
|
|
14
14
|
import "xe-utils";
|
|
@@ -19,86 +19,102 @@ import "../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.j
|
|
|
19
19
|
import "../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
|
|
20
20
|
import "../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
|
|
21
21
|
import "../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
|
|
22
|
-
import { omit as
|
|
22
|
+
import { omit as Te, isFunction as z } from "lodash-es";
|
|
23
23
|
import "vue-router";
|
|
24
|
-
import { TtText as
|
|
24
|
+
import { TtText as R } from "../../tt-text/index.js";
|
|
25
25
|
/* empty css */
|
|
26
|
-
import { ttUploadProps as
|
|
27
|
-
import { GlobalConfig as
|
|
28
|
-
import {
|
|
29
|
-
|
|
26
|
+
import { ttUploadProps as Se } from "./typing.js";
|
|
27
|
+
import { GlobalConfig as T } from "../../../hooks/useSetup.js";
|
|
28
|
+
import { getFileUrlOss as Ce } from "../../../api/oss.js";
|
|
29
|
+
import { useModalRender as xe } from "../../tt-modal/src/hooks/useModalRender.js";
|
|
30
|
+
const ao = /* @__PURE__ */ fe({
|
|
30
31
|
name: "TtUpload",
|
|
31
32
|
__name: "TtUpload",
|
|
32
|
-
props: /* @__PURE__ */
|
|
33
|
+
props: /* @__PURE__ */ B(Se, {
|
|
33
34
|
modelValue: {
|
|
34
35
|
default: () => []
|
|
35
36
|
},
|
|
36
37
|
modelModifiers: {}
|
|
37
38
|
}),
|
|
38
|
-
emits: /* @__PURE__ */
|
|
39
|
-
setup(
|
|
40
|
-
expose:
|
|
41
|
-
emit:
|
|
39
|
+
emits: /* @__PURE__ */ B(["afterUpload", "preview", "download", "delete", "templateDownload", "ok", "close", "error"], ["update:modelValue"]),
|
|
40
|
+
setup(S, {
|
|
41
|
+
expose: P,
|
|
42
|
+
emit: V
|
|
42
43
|
}) {
|
|
43
|
-
const
|
|
44
|
-
function
|
|
44
|
+
const N = ["modal", "modelValue", "ossType", "uploadOssApi", "uploadTip", "maxSize", "showFileList", "showUploadArea", "showTemplateDownload", "templateText", "showPreview", "showDownload", "showDelete", "gridThreshold", "gridColumns", "showCount", "uploadOssViewApi", "beforeUpload", "onError"], I = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg"]);
|
|
45
|
+
function K(e) {
|
|
45
46
|
var t;
|
|
46
47
|
const o = ((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "";
|
|
47
48
|
return I.has(o);
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
var
|
|
50
|
+
function D(e, o, t) {
|
|
51
|
+
var r;
|
|
51
52
|
if (!(t != null && t.trim())) return !0;
|
|
52
|
-
const l = e.includes(".") ? ((
|
|
53
|
-
return t.split(",").map((
|
|
53
|
+
const l = e.includes(".") ? ((r = e.split(".").pop()) == null ? void 0 : r.toLowerCase()) ?? "" : "";
|
|
54
|
+
return t.split(",").map((c) => c.trim()).filter(Boolean).some((c) => c.startsWith(".") ? l === c.slice(1).toLowerCase() : c.endsWith("/*") ? o.startsWith(c.slice(0, -1)) : o === c);
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
-
prefixCls:
|
|
57
|
-
} =
|
|
56
|
+
const a = S, p = V, u = me(S, "modelValue"), d = we(), {
|
|
57
|
+
prefixCls: i
|
|
58
|
+
} = he("upload"), C = U(), h = U(!1), x = U([]), [j, v] = xe({
|
|
58
59
|
onOk() {
|
|
59
|
-
|
|
60
|
+
p("ok", u.value);
|
|
60
61
|
},
|
|
61
62
|
onClose() {
|
|
62
|
-
v.closeModal(),
|
|
63
|
+
v.closeModal(), p("close");
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
function W() {
|
|
66
|
-
return [...
|
|
67
|
+
return [...u.value];
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
P({
|
|
69
70
|
openModal: () => {
|
|
70
|
-
|
|
71
|
+
a.showUploadArea && (u.value = []), v.openModal();
|
|
71
72
|
},
|
|
72
73
|
setModalProps: v.setModalProps,
|
|
73
74
|
closeModal: v.closeModal,
|
|
74
75
|
getFileList: W
|
|
75
76
|
});
|
|
76
|
-
const
|
|
77
|
+
const k = m(() => u.value.length > a.gridThreshold), _ = m(() => a.limit ?? 0), y = m(() => a.uploadOssApi ?? T.uploadOssApi), G = m(() => a.uploadOssViewApi ?? T.uploadOssViewApi ?? Ce);
|
|
77
78
|
async function q(e, o) {
|
|
78
|
-
const l =
|
|
79
|
-
r.append("key",
|
|
80
|
-
const
|
|
79
|
+
const l = (a.ossDir || o.dir || "notice").replace(/\/+$/, ""), s = l ? `${l}/${Date.now()}_${e.name}` : `${Date.now()}_${e.name}`, r = new FormData();
|
|
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);
|
|
81
|
+
const c = await fetch(o.host, {
|
|
81
82
|
method: "POST",
|
|
82
83
|
body: r
|
|
83
84
|
});
|
|
84
|
-
if (!
|
|
85
|
-
throw new Error(`OSS 上传失败: ${
|
|
86
|
-
return
|
|
85
|
+
if (!c.ok && c.status !== 203 && c.status !== 200)
|
|
86
|
+
throw new Error(`OSS 上传失败: ${c.status}`);
|
|
87
|
+
return s;
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
async function H(e, o) {
|
|
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), o.callback && r.append("callback", o.callback), r.append("success_action_status", "200"), r.append("file", e);
|
|
92
|
+
const c = await fetch(o.host, {
|
|
93
|
+
method: "POST",
|
|
94
|
+
body: r
|
|
95
|
+
});
|
|
96
|
+
if (!c.ok && c.status !== 204 && c.status !== 200)
|
|
97
|
+
throw new Error(`OBS 上传失败: ${c.status}`);
|
|
98
|
+
return s;
|
|
99
|
+
}
|
|
100
|
+
const X = m(() => a.ossType ?? T.ossType ?? "huawei");
|
|
101
|
+
async function Y(e, o) {
|
|
102
|
+
return X.value === "aliyun" ? q(e, o) : H(e, o);
|
|
103
|
+
}
|
|
104
|
+
function O(e) {
|
|
89
105
|
const o = e.uid;
|
|
90
|
-
|
|
106
|
+
u.value = u.value.filter((t) => {
|
|
91
107
|
var l;
|
|
92
108
|
return t.uid !== o && ((l = t.file) == null ? void 0 : l.uid) !== o;
|
|
93
109
|
});
|
|
94
110
|
}
|
|
95
|
-
function
|
|
96
|
-
throw
|
|
111
|
+
function L(e, o) {
|
|
112
|
+
throw O(o.file), e;
|
|
97
113
|
}
|
|
98
|
-
async function
|
|
114
|
+
async function J(e) {
|
|
99
115
|
var o;
|
|
100
116
|
try {
|
|
101
|
-
const t = e.file, l = URL.createObjectURL(t),
|
|
117
|
+
const t = e.file, l = URL.createObjectURL(t), s = {
|
|
102
118
|
fileName: t.name,
|
|
103
119
|
fileSize: t.size ?? 0,
|
|
104
120
|
fileSuffix: ((o = t.name.split(".").pop()) == null ? void 0 : o.toLowerCase()) || "",
|
|
@@ -106,214 +122,214 @@ const Ze = /* @__PURE__ */ de({
|
|
|
106
122
|
uid: t.uid,
|
|
107
123
|
url: l
|
|
108
124
|
};
|
|
109
|
-
return
|
|
125
|
+
return u.value = [...u.value, s], p("afterUpload", s), e.onSuccess(s), s;
|
|
110
126
|
} catch (t) {
|
|
111
|
-
|
|
127
|
+
f.warning((t == null ? void 0 : t.message) ?? "上传失败"), L(t, e);
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
|
-
async function
|
|
130
|
+
async function Q(e) {
|
|
115
131
|
var t;
|
|
116
|
-
const o =
|
|
132
|
+
const o = y.value;
|
|
117
133
|
try {
|
|
118
|
-
const l = await o(e.file),
|
|
134
|
+
const l = await o(e.file), s = await Y(e.file, l), r = a.ossDir || l.dir, c = {
|
|
119
135
|
fileName: e.file.name,
|
|
120
|
-
ossUploadBaseDir: l.dir,
|
|
121
|
-
ossKey: r,
|
|
122
136
|
fileSize: e.file.size ?? 0,
|
|
123
137
|
fileSuffix: ((t = e.file.name.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "",
|
|
124
138
|
file: e.file,
|
|
125
|
-
uid: e.file.uid
|
|
139
|
+
uid: e.file.uid,
|
|
140
|
+
ossKey: s,
|
|
141
|
+
ossUploadBaseDir: r
|
|
126
142
|
};
|
|
127
|
-
|
|
143
|
+
return u.value = [...u.value, c], f.success("上传成功"), p("afterUpload", c, s), e.onSuccess(c), c;
|
|
128
144
|
} catch (l) {
|
|
129
|
-
|
|
145
|
+
f.warning((l == null ? void 0 : l.message) ?? "上传失败"), L(l, e);
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
|
-
function
|
|
148
|
+
function Z(e, o, t) {
|
|
133
149
|
var l;
|
|
134
|
-
o.raw && (
|
|
150
|
+
o.raw && (O(o.raw), p("error", e, o.raw)), (l = a.onError) == null || l.call(a, e, o, t);
|
|
135
151
|
}
|
|
136
|
-
const
|
|
137
|
-
...
|
|
152
|
+
const ee = m(() => ({
|
|
153
|
+
...Te(a, N),
|
|
138
154
|
showFileList: !1,
|
|
139
|
-
beforeUpload:
|
|
140
|
-
onExceed:
|
|
141
|
-
onError:
|
|
155
|
+
beforeUpload: oe,
|
|
156
|
+
onExceed: te,
|
|
157
|
+
onError: Z,
|
|
142
158
|
action: "",
|
|
143
159
|
autoUpload: !0,
|
|
144
|
-
httpRequest:
|
|
160
|
+
httpRequest: y.value ? Q : J
|
|
145
161
|
}));
|
|
146
|
-
function
|
|
147
|
-
if (!
|
|
148
|
-
return
|
|
149
|
-
const o =
|
|
150
|
-
return
|
|
162
|
+
function oe(e) {
|
|
163
|
+
if (!D(e.name, e.type, a.accept))
|
|
164
|
+
return f.warning(`文件格式不支持,仅支持:${a.accept}`), !1;
|
|
165
|
+
const o = u.value.map((t) => $e(t.fileSize) || be(t.fileSize) ? +t.fileSize : 0).reduce((t, l) => t + l, 0);
|
|
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;
|
|
151
167
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
168
|
+
function te() {
|
|
169
|
+
f.warning("已超过上传数量");
|
|
154
170
|
}
|
|
155
|
-
function
|
|
171
|
+
function g(e) {
|
|
156
172
|
return e.ossKey ? e.ossKey : e.uid != null ? e.uid : e.fileName;
|
|
157
173
|
}
|
|
158
|
-
function
|
|
174
|
+
function le(e) {
|
|
159
175
|
var l;
|
|
160
|
-
const o =
|
|
176
|
+
const o = g(e);
|
|
161
177
|
if (!o)
|
|
162
178
|
throw new Error("No OssKey");
|
|
163
|
-
const t =
|
|
164
|
-
t.length !==
|
|
179
|
+
const t = u.value.filter((s) => g(s) !== o);
|
|
180
|
+
t.length !== u.value.length && (u.value = t), e.file && ((l = C.value) == null || l.handleRemove(e.file)), p("delete", e);
|
|
165
181
|
}
|
|
166
182
|
async function E(e) {
|
|
167
183
|
var t;
|
|
168
184
|
const o = G.value;
|
|
169
185
|
if (!(!o || !e.ossKey))
|
|
170
186
|
try {
|
|
171
|
-
const
|
|
187
|
+
const s = (t = (await o({
|
|
172
188
|
filePath: e.ossKey
|
|
173
|
-
})).find((
|
|
174
|
-
return e.url =
|
|
189
|
+
})).find((r) => r.fileName === e.ossKey)) == null ? void 0 : t.fileUrl;
|
|
190
|
+
return e.url = s, s;
|
|
175
191
|
} catch (l) {
|
|
176
|
-
|
|
192
|
+
f.warning((l == null ? void 0 : l.message) ?? "获取文件地址失败");
|
|
177
193
|
return;
|
|
178
194
|
}
|
|
179
195
|
}
|
|
180
|
-
async function
|
|
181
|
-
const l = await (await fetch(e)).blob(),
|
|
182
|
-
|
|
196
|
+
async function ae(e, o) {
|
|
197
|
+
const l = await (await fetch(e)).blob(), s = URL.createObjectURL(l), r = document.createElement("a");
|
|
198
|
+
r.href = s, r.download = o, r.click(), URL.revokeObjectURL(s);
|
|
183
199
|
}
|
|
184
|
-
async function
|
|
185
|
-
|
|
200
|
+
async function re(e) {
|
|
201
|
+
p("preview", e);
|
|
186
202
|
let o = await E(e);
|
|
187
|
-
|
|
203
|
+
y.value || (o = URL.createObjectURL(e.file)), o && (K(e.fileName) ? (x.value = [o], h.value = !0) : window.open(o, "_blank"));
|
|
188
204
|
}
|
|
189
|
-
async function
|
|
205
|
+
async function ne(e) {
|
|
190
206
|
let o = !1;
|
|
191
|
-
if (o =
|
|
192
|
-
|
|
207
|
+
if (o = z(a.beforeDownload) ? !!await a.beforeDownload(e) : a.beforeDownload, !o) {
|
|
208
|
+
p("download", e);
|
|
193
209
|
return;
|
|
194
210
|
}
|
|
195
211
|
let t;
|
|
196
|
-
|
|
212
|
+
y.value ? t = await E(e) : t = URL.createObjectURL(e.file), t && ae(t, e.fileName);
|
|
197
213
|
}
|
|
198
|
-
const
|
|
199
|
-
class: `${
|
|
200
|
-
}, [
|
|
201
|
-
ref:
|
|
202
|
-
},
|
|
214
|
+
const ie = () => a.showUploadArea ? n("div", {
|
|
215
|
+
class: `${i}-area`
|
|
216
|
+
}, [n(Ue, ye({
|
|
217
|
+
ref: C
|
|
218
|
+
}, ee.value), {
|
|
203
219
|
default: () => {
|
|
204
220
|
var e, o;
|
|
205
|
-
return [((e = d.uploadContent) == null ? void 0 : e.call(d)) ||
|
|
206
|
-
class: `${
|
|
207
|
-
}, [
|
|
208
|
-
icon:
|
|
221
|
+
return [((e = d.uploadContent) == null ? void 0 : e.call(d)) || n("div", {
|
|
222
|
+
class: `${i}-dragger`
|
|
223
|
+
}, [n(b, {
|
|
224
|
+
icon: ge,
|
|
209
225
|
size: 32,
|
|
210
226
|
isCustomSvg: !0
|
|
211
|
-
}, null),
|
|
212
|
-
class: `${
|
|
213
|
-
}, [w("上传附件")]),
|
|
214
|
-
class: `${
|
|
215
|
-
}, [((o = d.uploadTip) == null ? void 0 : o.call(d)) ||
|
|
216
|
-
class: `${
|
|
227
|
+
}, null), n("div", {
|
|
228
|
+
class: `${i}-dragger__text`
|
|
229
|
+
}, [w("上传附件")]), n("div", {
|
|
230
|
+
class: `${i}-dragger__tip`
|
|
231
|
+
}, [((o = d.uploadTip) == null ? void 0 : o.call(d)) || a.uploadTip]), a.showTemplateDownload && n("div", {
|
|
232
|
+
class: `${i}-dragger__template`,
|
|
217
233
|
onClick: (t) => {
|
|
218
|
-
t.stopPropagation(),
|
|
234
|
+
t.stopPropagation(), p("templateDownload");
|
|
219
235
|
}
|
|
220
|
-
}, [
|
|
236
|
+
}, [a.templateText])])];
|
|
221
237
|
}
|
|
222
|
-
})]) : null,
|
|
238
|
+
})]) : null, A = (e, o) => d.fileActions ? d.fileActions({
|
|
223
239
|
file: e,
|
|
224
240
|
index: o
|
|
225
|
-
}) :
|
|
226
|
-
class: `${
|
|
227
|
-
}, [
|
|
241
|
+
}) : n("div", {
|
|
242
|
+
class: `${i}-file__actions`
|
|
243
|
+
}, [a.showPreview && n($, {
|
|
228
244
|
type: "primary",
|
|
229
245
|
link: !0,
|
|
230
|
-
onClick: () =>
|
|
246
|
+
onClick: () => re(e)
|
|
231
247
|
}, {
|
|
232
248
|
default: () => [w("查看")]
|
|
233
|
-
}),
|
|
249
|
+
}), a.showDownload && n($, {
|
|
234
250
|
type: "primary",
|
|
235
251
|
link: !0,
|
|
236
|
-
onClick: () =>
|
|
252
|
+
onClick: () => ne(e)
|
|
237
253
|
}, {
|
|
238
254
|
default: () => [w("下载")]
|
|
239
|
-
}),
|
|
255
|
+
}), a.showDelete && !a.disabled && n($, {
|
|
240
256
|
type: "danger",
|
|
241
257
|
link: !0,
|
|
242
|
-
onClick: () =>
|
|
258
|
+
onClick: () => le(e)
|
|
243
259
|
}, {
|
|
244
260
|
default: () => [w("删除")]
|
|
245
|
-
})]),
|
|
246
|
-
class: `${
|
|
247
|
-
key:
|
|
248
|
-
}, [
|
|
249
|
-
class: `${
|
|
250
|
-
}, [
|
|
251
|
-
class: `${
|
|
252
|
-
}, [
|
|
253
|
-
icon:
|
|
261
|
+
})]), se = (e, o) => n("div", {
|
|
262
|
+
class: `${i}-file__card`,
|
|
263
|
+
key: g(e)
|
|
264
|
+
}, [n("div", {
|
|
265
|
+
class: `${i}-file__card-header`
|
|
266
|
+
}, [n("div", {
|
|
267
|
+
class: `${i}-file__card-icon`
|
|
268
|
+
}, [n(b, {
|
|
269
|
+
icon: M,
|
|
254
270
|
size: 28,
|
|
255
271
|
isCustomSvg: !0
|
|
256
|
-
}, null)]),
|
|
257
|
-
class: `${
|
|
258
|
-
}, [
|
|
259
|
-
class: `${
|
|
272
|
+
}, null)]), n("div", {
|
|
273
|
+
class: `${i}-file__card-info`
|
|
274
|
+
}, [n(R, {
|
|
275
|
+
class: `${i}-file__card-name`
|
|
260
276
|
}, {
|
|
261
277
|
default: () => [e.fileName]
|
|
262
|
-
})])]),
|
|
263
|
-
class: `${
|
|
264
|
-
}, [
|
|
265
|
-
class: `${
|
|
266
|
-
key:
|
|
267
|
-
}, [
|
|
268
|
-
class: `${
|
|
269
|
-
}, [
|
|
270
|
-
icon:
|
|
278
|
+
})])]), n("div", {
|
|
279
|
+
class: `${i}-file__card-footer`
|
|
280
|
+
}, [A(e, o)])]), ce = (e, o) => n("div", {
|
|
281
|
+
class: `${i}-file__row`,
|
|
282
|
+
key: g(e)
|
|
283
|
+
}, [n("div", {
|
|
284
|
+
class: `${i}-file__row-icon`
|
|
285
|
+
}, [n(b, {
|
|
286
|
+
icon: M,
|
|
271
287
|
size: 28,
|
|
272
288
|
isCustomSvg: !0
|
|
273
|
-
}, null)]),
|
|
274
|
-
class: `${
|
|
275
|
-
}, [
|
|
276
|
-
class: `${
|
|
289
|
+
}, null)]), n("div", {
|
|
290
|
+
class: `${i}-file__row-info`
|
|
291
|
+
}, [n(R, {
|
|
292
|
+
class: `${i}-file__row-name`
|
|
277
293
|
}, {
|
|
278
294
|
default: () => [e.fileName]
|
|
279
|
-
})]),
|
|
280
|
-
class: `${
|
|
281
|
-
}, [
|
|
295
|
+
})]), n("div", {
|
|
296
|
+
class: `${i}-file__row-actions`
|
|
297
|
+
}, [A(e, o)])]), ue = (e, o) => d.fileItem ? d.fileItem({
|
|
282
298
|
file: e,
|
|
283
299
|
index: o
|
|
284
|
-
}) :
|
|
285
|
-
if (!
|
|
286
|
-
const e =
|
|
287
|
-
gridTemplateColumns: `repeat(${
|
|
300
|
+
}) : k.value ? se(e, o) : ce(e, o), de = () => {
|
|
301
|
+
if (!a.showFileList || u.value.length === 0) return null;
|
|
302
|
+
const e = u.value.map((l, s) => ue(l, s)), o = k.value ? `${i}-filelist__grid` : `${i}-filelist__list`, t = k.value ? {
|
|
303
|
+
gridTemplateColumns: `repeat(${a.gridColumns}, 1fr)`
|
|
288
304
|
} : void 0;
|
|
289
|
-
return
|
|
290
|
-
class: `${
|
|
291
|
-
}, [
|
|
305
|
+
return n("div", {
|
|
306
|
+
class: `${i}-filelist`
|
|
307
|
+
}, [n("div", {
|
|
292
308
|
class: o,
|
|
293
309
|
style: t
|
|
294
|
-
}, [e]),
|
|
295
|
-
class: `${
|
|
296
|
-
}, [
|
|
297
|
-
class: `${
|
|
298
|
-
}, [
|
|
299
|
-
class: `${
|
|
300
|
-
}, [
|
|
301
|
-
},
|
|
310
|
+
}, [e]), a.showCount && _.value > 0 && n("div", {
|
|
311
|
+
class: `${i}-filelist__count`
|
|
312
|
+
}, [n("span", {
|
|
313
|
+
class: `${i}-filelist__count-current-number`
|
|
314
|
+
}, [u.value.length]), n("span", null, [w(" / ")]), n("span", {
|
|
315
|
+
class: `${i}-filelist__count-total-number`
|
|
316
|
+
}, [_.value])])]);
|
|
317
|
+
}, F = () => {
|
|
302
318
|
var e;
|
|
303
|
-
return
|
|
304
|
-
class:
|
|
305
|
-
}, [
|
|
306
|
-
urlList:
|
|
319
|
+
return n("div", {
|
|
320
|
+
class: i
|
|
321
|
+
}, [ie(), de(), (e = d.footer) == null ? void 0 : e.call(d), h.value && n(ke, {
|
|
322
|
+
urlList: x.value,
|
|
307
323
|
hideOnClickModal: !0,
|
|
308
324
|
teleported: !0,
|
|
309
|
-
onClose: () =>
|
|
325
|
+
onClose: () => h.value = !1
|
|
310
326
|
}, null)]);
|
|
311
|
-
},
|
|
312
|
-
default: () =>
|
|
313
|
-
}) :
|
|
314
|
-
return (e, o) => (
|
|
327
|
+
}, pe = () => a.modal ? n(j, null, {
|
|
328
|
+
default: () => F()
|
|
329
|
+
}) : F();
|
|
330
|
+
return (e, o) => (_e(), ve(pe));
|
|
315
331
|
}
|
|
316
332
|
});
|
|
317
333
|
export {
|
|
318
|
-
|
|
334
|
+
ao as default
|
|
319
335
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import { UploadRawFile } from 'element-plus';
|
|
3
|
+
export type OssType = "aliyun" | "huawei";
|
|
3
4
|
export interface OssSignatureResult {
|
|
4
5
|
/** HMAC-SHA256 签名 */
|
|
5
6
|
signature: string;
|
|
@@ -20,6 +21,31 @@ export interface OssSignatureResult {
|
|
|
20
21
|
/** Base64 编码的上传策略 */
|
|
21
22
|
policy: string;
|
|
22
23
|
}
|
|
24
|
+
export interface HuaweiObsSignatureResult {
|
|
25
|
+
/** 访问密钥 ID */
|
|
26
|
+
accessKeyId: string;
|
|
27
|
+
/** 存储桶名称 */
|
|
28
|
+
bucket?: string;
|
|
29
|
+
/** 回调地址 */
|
|
30
|
+
callbackUrl?: string;
|
|
31
|
+
/** 回调请求体内容 */
|
|
32
|
+
callbackBody?: string;
|
|
33
|
+
/** 回调请求体类型 */
|
|
34
|
+
callbackBodyType?: string;
|
|
35
|
+
/** 兼容 base64 回调参数 */
|
|
36
|
+
callback?: string;
|
|
37
|
+
/** 文件存储目录前缀 */
|
|
38
|
+
dir: string;
|
|
39
|
+
/** OBS 上传域名 / 地址 */
|
|
40
|
+
host: string;
|
|
41
|
+
/** Base64 编码的上传策略 */
|
|
42
|
+
policy: string;
|
|
43
|
+
/** 临时访问令牌(STS Token) */
|
|
44
|
+
security_token?: string;
|
|
45
|
+
/** HMAC-SHA1 签名 */
|
|
46
|
+
signature: string;
|
|
47
|
+
}
|
|
48
|
+
export type UnifiedOssSignatureResult = OssSignatureResult | HuaweiObsSignatureResult | Record<string, unknown>;
|
|
23
49
|
export interface TtUploadFileItem {
|
|
24
50
|
/** 文件名 */
|
|
25
51
|
fileName: string;
|
|
@@ -83,12 +109,12 @@ export declare const ttUploadProps: {
|
|
|
83
109
|
};
|
|
84
110
|
/** 获取 OSS 签名信息的接口 ,不传则使用全局 setup 的 uploadOssApi */
|
|
85
111
|
readonly uploadOssApi: {
|
|
86
|
-
readonly type: PropType<(file
|
|
112
|
+
readonly type: PropType<(file?: any) => Promise<any>>;
|
|
87
113
|
readonly default: undefined;
|
|
88
114
|
};
|
|
89
115
|
/** 根据 ossKey 获取文件预览/下载 URL 的接口,不传则使用全局 setup 的 uploadOssViewApi */
|
|
90
116
|
readonly uploadOssViewApi: {
|
|
91
|
-
readonly type: PropType<(key: string) => Promise<any
|
|
117
|
+
readonly type: PropType<((key: string) => Promise<any>) | ((params: any) => Promise<any>)>;
|
|
92
118
|
readonly default: undefined;
|
|
93
119
|
};
|
|
94
120
|
/** 上传提示文字 */
|
|
@@ -156,6 +182,11 @@ export declare const ttUploadProps: {
|
|
|
156
182
|
readonly type: PropType<boolean>;
|
|
157
183
|
readonly default: true;
|
|
158
184
|
};
|
|
185
|
+
/** 云存储类型,默认 huawei */
|
|
186
|
+
readonly ossType: {
|
|
187
|
+
readonly type: PropType<OssType>;
|
|
188
|
+
readonly default: undefined;
|
|
189
|
+
};
|
|
159
190
|
/** 自定义oss存储目录 */
|
|
160
191
|
readonly ossDir: {
|
|
161
192
|
readonly type: PropType<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VxeGridPropTypes, VxeTablePropTypes } from 'vxe-table';
|
|
2
2
|
import { TtTableProps } from './tt-table/src/types/table';
|
|
3
|
-
import {
|
|
3
|
+
import { OssType, UnifiedOssSignatureResult } from './tt-upload/src/typing';
|
|
4
4
|
export type Fn<T = any, R = T> = (...arg: T[]) => R;
|
|
5
5
|
export type Nullable<T> = T | null;
|
|
6
6
|
export type Recordable<T = any> = Record<string, T>;
|
|
@@ -13,10 +13,12 @@ export type TtUiGlobalConfig = {
|
|
|
13
13
|
* 登录的用户id
|
|
14
14
|
*/
|
|
15
15
|
userId?: string | number;
|
|
16
|
+
/** 云存储类型,默认 huawei */
|
|
17
|
+
ossType?: OssType;
|
|
16
18
|
/** 获取 OSS 签名信息的接口(服务端签名直传) */
|
|
17
|
-
uploadOssApi?: (file
|
|
19
|
+
uploadOssApi?: (file?: any) => Promise<UnifiedOssSignatureResult | any>;
|
|
18
20
|
/** 根据 ossKey 获取文件预览/下载 URL 的接口 */
|
|
19
|
-
uploadOssViewApi?: (key: string) => Promise<
|
|
21
|
+
uploadOssViewApi?: ((key: string) => Promise<any>) | ((params: any) => Promise<any>);
|
|
20
22
|
table?: {
|
|
21
23
|
/** 自定义列服务端配置的key,支持函数动态获取 */
|
|
22
24
|
columnsKey?: string | (() => string);
|
|
@@ -163,7 +165,7 @@ export type TtUiGlobalConfig = {
|
|
|
163
165
|
*/
|
|
164
166
|
isReloadResetToFirstPage?: boolean;
|
|
165
167
|
};
|
|
166
|
-
form
|
|
168
|
+
form?: {
|
|
167
169
|
/**
|
|
168
170
|
* 表单的提交按钮字段
|
|
169
171
|
* @default-查询
|