@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.
@@ -1,14 +1,14 @@
1
- import { defineComponent as de, mergeModels as M, useModel as ce, useSlots as pe, ref as b, computed as m, createBlock as fe, openBlock as me, createVNode as a, mergeProps as we, createTextVNode as w } from "vue";
2
- import ve from "../../../assets/svg/exportSvg.svg.js";
3
- import z from "../../../assets/svg/fileSvg.svg.js";
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 S } from "../../tt-icon/index.js";
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 ge } from "../../../packages/hooks/src/useDesign.js";
8
+ import { useDesign as he } from "../../../packages/hooks/src/useDesign.js";
9
9
  import "axios";
10
- import { ElMessage as p, ElImageViewer as _e, ElUpload as he } from "element-plus";
11
- import { isString as Ue, isNumber as ye } from "../../../packages/utils/src/is.js";
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 be, isFunction as R } from "lodash-es";
22
+ import { omit as Te, isFunction as z } from "lodash-es";
23
23
  import "vue-router";
24
- import { TtText as V } from "../../tt-text/index.js";
24
+ import { TtText as R } from "../../tt-text/index.js";
25
25
  /* empty css */
26
- import { ttUploadProps as $e } from "./typing.js";
27
- import { GlobalConfig as F } from "../../../hooks/useSetup.js";
28
- import { useModalRender as Se } from "../../tt-modal/src/hooks/useModalRender.js";
29
- const Ze = /* @__PURE__ */ de({
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__ */ M($e, {
33
+ props: /* @__PURE__ */ B(Se, {
33
34
  modelValue: {
34
35
  default: () => []
35
36
  },
36
37
  modelModifiers: {}
37
38
  }),
38
- emits: /* @__PURE__ */ M(["afterUpload", "preview", "download", "delete", "templateDownload", "ok", "close", "error"], ["update:modelValue"]),
39
- setup(C, {
40
- expose: N,
41
- emit: P
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 D = ["modal", "modelValue", "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"]);
44
- function B(e) {
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 K(e, o, t) {
50
- var u;
50
+ function D(e, o, t) {
51
+ var r;
51
52
  if (!(t != null && t.trim())) return !0;
52
- const l = e.includes(".") ? ((u = e.split(".").pop()) == null ? void 0 : u.toLowerCase()) ?? "" : "";
53
- return t.split(",").map((f) => f.trim()).filter(Boolean).some((f) => f.startsWith(".") ? l === f.slice(1).toLowerCase() : f.endsWith("/*") ? o.startsWith(f.slice(0, -1)) : o === f);
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 i = C, c = P, s = ce(C, "modelValue"), d = pe(), {
56
- prefixCls: n
57
- } = ge("upload"), x = b(), U = b(!1), k = b([]), [j, v] = Se({
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
- c("ok", s.value);
60
+ p("ok", u.value);
60
61
  },
61
62
  onClose() {
62
- v.closeModal(), c("close");
63
+ v.closeModal(), p("close");
63
64
  }
64
65
  });
65
66
  function W() {
66
- return [...s.value];
67
+ return [...u.value];
67
68
  }
68
- N({
69
+ P({
69
70
  openModal: () => {
70
- i.showUploadArea && (s.value = []), v.openModal();
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 y = m(() => s.value.length > i.gridThreshold), g = m(() => i.limit ?? 0), _ = m(() => i.uploadOssApi ?? F.uploadOssApi), G = m(() => i.uploadOssViewApi ?? F.uploadOssViewApi);
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 = `${i.ossDir || o.dir || "notice"}/${Date.now()}_${e.name}`, r = new FormData();
79
- r.append("key", l), 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);
80
- const u = await fetch(o.host, {
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 (!u.ok && u.status !== 203)
85
- throw new Error(`OSS 上传失败: ${u.status}`);
86
- return l;
85
+ if (!c.ok && c.status !== 203 && c.status !== 200)
86
+ throw new Error(`OSS 上传失败: ${c.status}`);
87
+ return s;
87
88
  }
88
- function L(e) {
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
- s.value = s.value.filter((t) => {
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 T(e, o) {
96
- throw L(o.file), e;
111
+ function L(e, o) {
112
+ throw O(o.file), e;
97
113
  }
98
- async function X(e) {
114
+ async function J(e) {
99
115
  var o;
100
116
  try {
101
- const t = e.file, l = URL.createObjectURL(t), r = {
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 s.value = [...s.value, r], c("afterUpload", r), e.onSuccess(r), r;
125
+ return u.value = [...u.value, s], p("afterUpload", s), e.onSuccess(s), s;
110
126
  } catch (t) {
111
- p.warning((t == null ? void 0 : t.message) ?? "上传失败"), T(t, e);
127
+ f.warning((t == null ? void 0 : t.message) ?? "上传失败"), L(t, e);
112
128
  }
113
129
  }
114
- async function Y(e) {
130
+ async function Q(e) {
115
131
  var t;
116
- const o = _.value;
132
+ const o = y.value;
117
133
  try {
118
- const l = await o(e.file), r = await q(e.file, l), u = {
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
- s.value = [...s.value, u], p.success("上传成功"), c("afterUpload", u), e.onSuccess(l);
143
+ return u.value = [...u.value, c], f.success("上传成功"), p("afterUpload", c, s), e.onSuccess(c), c;
128
144
  } catch (l) {
129
- p.warning((l == null ? void 0 : l.message) ?? "上传失败"), T(l, e);
145
+ f.warning((l == null ? void 0 : l.message) ?? "上传失败"), L(l, e);
130
146
  }
131
147
  }
132
- function H(e, o, t) {
148
+ function Z(e, o, t) {
133
149
  var l;
134
- o.raw && (L(o.raw), c("error", e, o.raw)), (l = i.onError) == null || l.call(i, e, o, t);
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 J = m(() => ({
137
- ...be(i, D),
152
+ const ee = m(() => ({
153
+ ...Te(a, N),
138
154
  showFileList: !1,
139
- beforeUpload: Q,
140
- onExceed: Z,
141
- onError: H,
155
+ beforeUpload: oe,
156
+ onExceed: te,
157
+ onError: Z,
142
158
  action: "",
143
159
  autoUpload: !0,
144
- httpRequest: _.value ? Y : X
160
+ httpRequest: y.value ? Q : J
145
161
  }));
146
- function Q(e) {
147
- if (!K(e.name, e.type, i.accept))
148
- return p.warning(`文件格式不支持,仅支持:${i.accept}`), !1;
149
- const o = s.value.map((t) => Ue(t.fileSize) || ye(t.fileSize) ? +t.fileSize : 0).reduce((t, l) => t + l, 0);
150
- return i.maxSize && (e.size + o) / 1024 / 1024 > i.maxSize ? (p.warning(`文件大小不能超过 ${i.maxSize}MB`), !1) : g.value > 0 && s.value.length >= g.value ? (p.warning("已超过上传数量"), !1) : R(i.beforeUpload) ? i.beforeUpload(e) : !0;
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 Z() {
153
- p.warning("已超过上传数量");
168
+ function te() {
169
+ f.warning("已超过上传数量");
154
170
  }
155
- function h(e) {
171
+ function g(e) {
156
172
  return e.ossKey ? e.ossKey : e.uid != null ? e.uid : e.fileName;
157
173
  }
158
- function ee(e) {
174
+ function le(e) {
159
175
  var l;
160
- const o = h(e);
176
+ const o = g(e);
161
177
  if (!o)
162
178
  throw new Error("No OssKey");
163
- const t = s.value.filter((r) => h(r) !== o);
164
- t.length !== s.value.length && (s.value = t), e.file && ((l = x.value) == null || l.handleRemove(e.file)), c("delete", e);
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 r = (t = (await o({
187
+ const s = (t = (await o({
172
188
  filePath: e.ossKey
173
- })).find((u) => u.fileName === e.ossKey)) == null ? void 0 : t.fileUrl;
174
- return e.url = r, r;
189
+ })).find((r) => r.fileName === e.ossKey)) == null ? void 0 : t.fileUrl;
190
+ return e.url = s, s;
175
191
  } catch (l) {
176
- p.warning((l == null ? void 0 : l.message) ?? "获取文件地址失败");
192
+ f.warning((l == null ? void 0 : l.message) ?? "获取文件地址失败");
177
193
  return;
178
194
  }
179
195
  }
180
- async function oe(e, o) {
181
- const l = await (await fetch(e)).blob(), r = URL.createObjectURL(l), u = document.createElement("a");
182
- u.href = r, u.download = o, u.click(), URL.revokeObjectURL(r);
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 te(e) {
185
- c("preview", e);
200
+ async function re(e) {
201
+ p("preview", e);
186
202
  let o = await E(e);
187
- _.value || (o = URL.createObjectURL(e.file)), o && (B(e.fileName) ? (k.value = [o], U.value = !0) : window.open(o, "_blank"));
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 le(e) {
205
+ async function ne(e) {
190
206
  let o = !1;
191
- if (o = R(i.beforeDownload) ? !!await i.beforeDownload(e) : i.beforeDownload, !o) {
192
- c("download", e);
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
- _.value ? t = await E(e) : t = URL.createObjectURL(e.file), t && oe(t, e.fileName);
212
+ y.value ? t = await E(e) : t = URL.createObjectURL(e.file), t && ae(t, e.fileName);
197
213
  }
198
- const ae = () => i.showUploadArea ? a("div", {
199
- class: `${n}-area`
200
- }, [a(he, we({
201
- ref: x
202
- }, J.value), {
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)) || a("div", {
206
- class: `${n}-dragger`
207
- }, [a(S, {
208
- icon: ve,
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), a("div", {
212
- class: `${n}-dragger__text`
213
- }, [w("上传附件")]), a("div", {
214
- class: `${n}-dragger__tip`
215
- }, [((o = d.uploadTip) == null ? void 0 : o.call(d)) || i.uploadTip]), i.showTemplateDownload && a("div", {
216
- class: `${n}-dragger__template`,
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(), c("templateDownload");
234
+ t.stopPropagation(), p("templateDownload");
219
235
  }
220
- }, [i.templateText])])];
236
+ }, [a.templateText])])];
221
237
  }
222
- })]) : null, O = (e, o) => d.fileActions ? d.fileActions({
238
+ })]) : null, A = (e, o) => d.fileActions ? d.fileActions({
223
239
  file: e,
224
240
  index: o
225
- }) : a("div", {
226
- class: `${n}-file__actions`
227
- }, [i.showPreview && a($, {
241
+ }) : n("div", {
242
+ class: `${i}-file__actions`
243
+ }, [a.showPreview && n($, {
228
244
  type: "primary",
229
245
  link: !0,
230
- onClick: () => te(e)
246
+ onClick: () => re(e)
231
247
  }, {
232
248
  default: () => [w("查看")]
233
- }), i.showDownload && a($, {
249
+ }), a.showDownload && n($, {
234
250
  type: "primary",
235
251
  link: !0,
236
- onClick: () => le(e)
252
+ onClick: () => ne(e)
237
253
  }, {
238
254
  default: () => [w("下载")]
239
- }), i.showDelete && !i.disabled && a($, {
255
+ }), a.showDelete && !a.disabled && n($, {
240
256
  type: "danger",
241
257
  link: !0,
242
- onClick: () => ee(e)
258
+ onClick: () => le(e)
243
259
  }, {
244
260
  default: () => [w("删除")]
245
- })]), ie = (e, o) => a("div", {
246
- class: `${n}-file__card`,
247
- key: h(e)
248
- }, [a("div", {
249
- class: `${n}-file__card-header`
250
- }, [a("div", {
251
- class: `${n}-file__card-icon`
252
- }, [a(S, {
253
- icon: z,
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)]), a("div", {
257
- class: `${n}-file__card-info`
258
- }, [a(V, {
259
- class: `${n}-file__card-name`
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
- })])]), a("div", {
263
- class: `${n}-file__card-footer`
264
- }, [O(e, o)])]), re = (e, o) => a("div", {
265
- class: `${n}-file__row`,
266
- key: h(e)
267
- }, [a("div", {
268
- class: `${n}-file__row-icon`
269
- }, [a(S, {
270
- icon: z,
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)]), a("div", {
274
- class: `${n}-file__row-info`
275
- }, [a(V, {
276
- class: `${n}-file__row-name`
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
- })]), a("div", {
280
- class: `${n}-file__row-actions`
281
- }, [O(e, o)])]), ne = (e, o) => d.fileItem ? d.fileItem({
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
- }) : y.value ? ie(e, o) : re(e, o), se = () => {
285
- if (!i.showFileList || s.value.length === 0) return null;
286
- const e = s.value.map((l, r) => ne(l, r)), o = y.value ? `${n}-filelist__grid` : `${n}-filelist__list`, t = y.value ? {
287
- gridTemplateColumns: `repeat(${i.gridColumns}, 1fr)`
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 a("div", {
290
- class: `${n}-filelist`
291
- }, [a("div", {
305
+ return n("div", {
306
+ class: `${i}-filelist`
307
+ }, [n("div", {
292
308
  class: o,
293
309
  style: t
294
- }, [e]), i.showCount && g.value > 0 && a("div", {
295
- class: `${n}-filelist__count`
296
- }, [a("span", {
297
- class: `${n}-filelist__count-current-number`
298
- }, [s.value.length]), a("span", null, [w(" / ")]), a("span", {
299
- class: `${n}-filelist__count-total-number`
300
- }, [g.value])])]);
301
- }, A = () => {
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 a("div", {
304
- class: n
305
- }, [ae(), se(), (e = d.footer) == null ? void 0 : e.call(d), U.value && a(_e, {
306
- urlList: k.value,
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: () => U.value = !1
325
+ onClose: () => h.value = !1
310
326
  }, null)]);
311
- }, ue = () => i.modal ? a(j, null, {
312
- default: () => A()
313
- }) : A();
314
- return (e, o) => (me(), fe(ue));
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
- Ze as default
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: File) => Promise<any>> | undefined | null;
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>;
@@ -103,6 +103,11 @@ const o = {
103
103
  type: Boolean,
104
104
  default: !0
105
105
  },
106
+ /** 云存储类型,默认 huawei */
107
+ ossType: {
108
+ type: String,
109
+ default: void 0
110
+ },
106
111
  /** 自定义oss存储目录 */
107
112
  ossDir: {
108
113
  type: 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 { OssSignatureResult } from './tt-upload/src/typing';
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: File) => Promise<OssSignatureResult>;
19
+ uploadOssApi?: (file?: any) => Promise<UnifiedOssSignatureResult | any>;
18
20
  /** 根据 ossKey 获取文件预览/下载 URL 的接口 */
19
- uploadOssViewApi?: (key: string) => Promise<string>;
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-查询