@aplus-frontend/ui 0.2.3 → 0.2.5

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.
@@ -53,6 +53,9 @@ declare const __VLS_component: DefineComponent<{
53
53
  type: PropType<GetOssAccess>;
54
54
  };
55
55
  onChange: FunctionConstructor;
56
+ maxSizeErrorMsg: StringConstructor;
57
+ maxCountErrorMsg: StringConstructor;
58
+ acceptErrorMsg: StringConstructor;
56
59
  }, {
57
60
  done: ComputedRef<boolean>;
58
61
  clear: typeof clear;
@@ -101,6 +104,9 @@ declare const __VLS_component: DefineComponent<{
101
104
  type: PropType<GetOssAccess>;
102
105
  };
103
106
  onChange: FunctionConstructor;
107
+ maxSizeErrorMsg: StringConstructor;
108
+ maxCountErrorMsg: StringConstructor;
109
+ acceptErrorMsg: StringConstructor;
104
110
  }>> & {
105
111
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
106
112
  }, {
@@ -1,4 +1,4 @@
1
- import { defineComponent as k, ref as g, computed as v, provide as t, openBlock as y, createElementBlock as z, normalizeClass as T, unref as B, createBlock as L, resolveDynamicComponent as R, mergeProps as q, createSlots as P, renderList as M, withCtx as V, renderSlot as w, normalizeProps as D, guardReactiveProps as E } from "vue";
1
+ import { defineComponent as A, ref as f, computed as v, provide as t, openBlock as y, createElementBlock as U, normalizeClass as $, unref as k, createBlock as T, resolveDynamicComponent as B, mergeProps as L, createSlots as R, renderList as q, withCtx as P, renderSlot as V, normalizeProps as w, guardReactiveProps as D } from "vue";
2
2
  import "../config-provider/index.mjs";
3
3
  import "./components/SingleFile.vue.mjs";
4
4
  import "./components/MultipleFile.vue.mjs";
@@ -11,8 +11,8 @@ import { useNamespace as K } from "../config-provider/hooks/use-namespace.mjs";
11
11
  import Q from "./components/SingleFile.vue2.mjs";
12
12
  import W from "./components/MultipleFile.vue2.mjs";
13
13
  import X from "./components/Picture.vue2.mjs";
14
- import { useGlobalConfig as b } from "../config-provider/hooks/use-global-config.mjs";
15
- const ue = /* @__PURE__ */ k({
14
+ import { useGlobalConfig as C } from "../config-provider/hooks/use-global-config.mjs";
15
+ const ue = /* @__PURE__ */ A({
16
16
  name: "AplusFileUpload",
17
17
  __name: "apUpload",
18
18
  props: {
@@ -56,57 +56,60 @@ const ue = /* @__PURE__ */ k({
56
56
  getOssAccess: {
57
57
  type: Function
58
58
  },
59
- onChange: Function
59
+ onChange: Function,
60
+ maxSizeErrorMsg: String,
61
+ maxCountErrorMsg: String,
62
+ acceptErrorMsg: String
60
63
  },
61
64
  emits: ["update:value"],
62
- setup(C, { expose: N, emit: _ }) {
63
- var p, u, d, f;
64
- const { t: c, lang: F } = J();
65
- G(c), I(c, F);
66
- const { b: S } = K("ap-upload"), s = g(null), e = C, O = _, h = {
65
+ setup(S, { expose: b, emit: x }) {
66
+ var l, u, d, g;
67
+ const { t: c, lang: M } = J();
68
+ G(c), I(c, M);
69
+ const { b: N } = K("ap-upload"), n = f(null), e = S, _ = x, E = {
67
70
  singleFile: Q,
68
71
  multipleFile: W,
69
72
  picture: X
70
- }, i = H.useInjectFormItemContext(), j = v({
73
+ }, i = H.useInjectFormItemContext(), F = v({
71
74
  get() {
72
75
  return e.value;
73
76
  },
74
77
  set(o) {
75
- var a;
76
- O("update:value", o), i == null || i.onFieldChange(), (a = e.onChange) == null || a.call(e, o);
78
+ var r;
79
+ _("update:value", o), i == null || i.onFieldChange(), (r = e.onChange) == null || r.call(e, o);
77
80
  }
78
- }), x = b("uiMode"), r = b("apUpload");
79
- t("theme", x.value), t("value", j), t("dirName", e.dirName ?? ((p = r.value) == null ? void 0 : p.dirName)), t(
81
+ }), O = C("uiMode"), s = C("apUpload");
82
+ t("theme", O.value), t("value", F), t("dirName", e.dirName ?? ((l = s.value) == null ? void 0 : l.dirName)), t(
80
83
  "needName",
81
- e.needName ?? ((u = r.value) == null ? void 0 : u.needName) ?? !1
82
- ), t("accept", e.accept ?? ((d = r.value) == null ? void 0 : d.accept) ?? ""), t("maxSize", e.maxSize), t("title", e.title), t("subTitle", e.subTitle), t("maxCount", e.maxCount), t("beforeUpload", e.beforeUpload), t("customRequest", e.customRequest), t(
84
+ e.needName ?? ((u = s.value) == null ? void 0 : u.needName) ?? !1
85
+ ), t("accept", e.accept ?? ((d = s.value) == null ? void 0 : d.accept) ?? ""), t("maxSize", e.maxSize), t("title", e.title), t("subTitle", e.subTitle), t("maxCount", e.maxCount), t("beforeUpload", e.beforeUpload), t("customRequest", e.customRequest), t(
83
86
  "getOssAccess",
84
- e.getOssAccess ?? ((f = r.value) == null ? void 0 : f.getOssAccess)
85
- );
86
- const A = v(() => l.value === 0), l = g(0);
87
- t("uploadingCount", l);
88
- function U() {
89
- m(void 0);
87
+ e.getOssAccess ?? ((g = s.value) == null ? void 0 : g.getOssAccess)
88
+ ), t("maxSizeErrorMsg", e.maxSizeErrorMsg), t("maxCountErrorMsg", e.maxCountErrorMsg), t("acceptErrorMsg", e.acceptErrorMsg);
89
+ const z = v(() => m.value === 0), m = f(0);
90
+ t("uploadingCount", m);
91
+ function h() {
92
+ p(void 0);
90
93
  }
91
- function m(o) {
92
- var a, n;
93
- (n = (a = s == null ? void 0 : s.value) == null ? void 0 : a.setValue) == null || n.call(a, o);
94
+ function p(o) {
95
+ var r, a;
96
+ (a = (r = n == null ? void 0 : n.value) == null ? void 0 : r.setValue) == null || a.call(r, o);
94
97
  }
95
- return N({
96
- done: A,
97
- clear: U,
98
- setValue: m
99
- }), (o, a) => (y(), z("div", {
100
- class: T(B(S)())
98
+ return b({
99
+ done: z,
100
+ clear: h,
101
+ setValue: p
102
+ }), (o, r) => (y(), U("div", {
103
+ class: $(k(N)())
101
104
  }, [
102
- (y(), L(R(h[e.type]), q(o.$attrs, {
105
+ (y(), T(B(E[e.type]), L(o.$attrs, {
103
106
  ref_key: "uploadRef",
104
- ref: s
105
- }), P({ _: 2 }, [
106
- M(Object.keys(o.$slots), (n) => ({
107
- name: n,
108
- fn: V(($) => [
109
- w(o.$slots, n, D(E($ || {})))
107
+ ref: n
108
+ }), R({ _: 2 }, [
109
+ q(Object.keys(o.$slots), (a) => ({
110
+ name: a,
111
+ fn: P((j) => [
112
+ V(o.$slots, a, w(D(j || {})))
110
113
  ])
111
114
  }))
112
115
  ]), 1040))
@@ -45,6 +45,18 @@ export type FileUploadProps = {
45
45
  * 默认为name,path
46
46
  */
47
47
  needName?: NeedNameModel;
48
+ /**
49
+ * 超出文件大小错误提示
50
+ */
51
+ maxSizeErrorMsg?: string;
52
+ /**
53
+ * 超出文件数量错误提示
54
+ */
55
+ maxCountErrorMsg?: string;
56
+ /**
57
+ * 文件类型错误提示
58
+ */
59
+ acceptErrorMsg?: string;
48
60
  };
49
61
  export type SingleFileProps = FileUploadProps & {
50
62
  /**
@@ -1,56 +1,56 @@
1
- import { defineComponent as $, inject as n, ref as j, watch as V, nextTick as W, openBlock as h, createElementBlock as k, normalizeClass as G, unref as s, createVNode as C, withCtx as E, createElementVNode as L, createTextVNode as H, toDisplayString as b, withModifiers as J, createBlock as K, resolveDynamicComponent as Q, createCommentVNode as X } from "vue";
1
+ import { defineComponent as W, inject as a, ref as G, watch as H, nextTick as J, openBlock as x, createElementBlock as C, normalizeClass as K, unref as n, createVNode as k, withCtx as T, createElementVNode as S, createTextVNode as Q, toDisplayString as L, withModifiers as X, createBlock as Y, resolveDynamicComponent as Z, createCommentVNode as ee } from "vue";
2
2
  import "../../config-provider/index.mjs";
3
- import { getPath as Y, getName as Z, getReturnData as S } from "../utils/returnData.mjs";
4
- import { useOss as ee, getOssInstance as te } from "../hooks/useOss.mjs";
5
- import { message as m, Upload as oe, Button as ae } from "@aplus-frontend/antdv";
6
- import { UploadOutlined as se } from "@ant-design/icons-vue";
7
- import { fileMatchesAccept as ne, getAcceptText as ie } from "../utils/accept.mjs";
8
- import { useLocale as re } from "../../config-provider/hooks/use-locale.mjs";
9
- import { useNamespace as le } from "../../config-provider/hooks/use-namespace.mjs";
10
- const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 }, Ce = /* @__PURE__ */ $({
3
+ import { getPath as te, getName as oe, getReturnData as M } from "../utils/returnData.mjs";
4
+ import { useOss as se, getOssInstance as ae } from "../hooks/useOss.mjs";
5
+ import { message as m, Upload as ne, Button as re } from "@aplus-frontend/antdv";
6
+ import { UploadOutlined as ie } from "@ant-design/icons-vue";
7
+ import { fileMatchesAccept as le, getAcceptText as ue } from "../utils/accept.mjs";
8
+ import { useLocale as ce } from "../../config-provider/hooks/use-locale.mjs";
9
+ import { useNamespace as pe } from "../../config-provider/hooks/use-namespace.mjs";
10
+ const me = { class: "multiple-file-context" }, de = { key: 0 }, fe = { key: 1 }, _e = /* @__PURE__ */ W({
11
11
  __name: "MultipleFile",
12
- setup(me, { expose: B }) {
13
- const { t: i } = re(), { b: U } = le("ap-upload-multiple-file"), { put: I } = ee(), P = n("theme"), z = n("dirName"), x = n("accept") || "*", _ = n("maxSize") ?? 500, R = n("title") || i("ap.apUpload.uploadFile"), f = n("subTitle"), r = n("maxCount") ?? 10, d = n("uploadingCount"), A = n("beforeUpload"), F = n("customRequest"), O = n("getOssAccess"), a = n("value"), p = [], g = n("needName"), l = j(null);
14
- V(
15
- () => a == null ? void 0 : a.value,
12
+ setup(ge, { expose: b }) {
13
+ const { t: r } = ce(), { b: E } = pe("ap-upload-multiple-file"), { put: z } = se(), B = a("theme"), I = a("dirName"), h = a("accept") || "*", U = a("maxSize") ?? 500, P = a("title") || r("ap.apUpload.uploadFile"), f = a("subTitle"), i = a("maxCount") ?? 10, d = a("uploadingCount"), _ = a("beforeUpload"), A = a("customRequest"), R = a("getOssAccess"), O = a("maxSizeErrorMsg"), q = a("maxCountErrorMsg"), D = a("acceptErrorMsg"), s = a("value"), c = [], g = a("needName"), l = G(null);
14
+ H(
15
+ () => s == null ? void 0 : s.value,
16
16
  function(e) {
17
17
  var t, o;
18
- !((o = (t = l == null ? void 0 : l.value) == null ? void 0 : t.fileList) != null && o.length) && e && N(e);
18
+ !((o = (t = l == null ? void 0 : l.value) == null ? void 0 : t.fileList) != null && o.length) && e && F(e);
19
19
  },
20
20
  { immediate: !0 }
21
21
  );
22
- function N(e) {
22
+ function F(e) {
23
23
  if (!e) {
24
- c = [], l.value.fileList = [], a.value = void 0, p.splice(0, p.length);
24
+ p = [], l.value.fileList = [], s.value = void 0, c.splice(0, c.length);
25
25
  return;
26
26
  }
27
- W(() => {
27
+ J(() => {
28
28
  const t = e.map((o) => {
29
- const u = Y(g, o), y = Z(g, o), w = new File(
29
+ const u = te(g, o), y = oe(g, o), w = new File(
30
30
  [o],
31
31
  y,
32
32
  {}
33
33
  );
34
34
  return w.response = u, w.uid = u, w;
35
35
  });
36
- if (r && t.length > r) {
36
+ if (i && t.length > i) {
37
37
  m.warning(
38
- i("ap.apUpload.fileInitializationException", {
39
- maxCount: r
38
+ r("ap.apUpload.fileInitializationException", {
39
+ maxCount: i
40
40
  })
41
41
  );
42
42
  return;
43
43
  }
44
44
  t.forEach((o) => {
45
- c.push(o), p.push({
45
+ p.push(o), c.push({
46
46
  uid: o.uid,
47
47
  path: o.response
48
48
  });
49
- }), l.value.fileList = t, a.value = e;
49
+ }), l.value.fileList = t, s.value = e;
50
50
  });
51
51
  }
52
- B({ setValue: N });
53
- let c = [], T;
52
+ b({ setValue: F });
53
+ let p = [], N;
54
54
  function v(e) {
55
55
  setTimeout(() => {
56
56
  const t = l.value.fileList.findIndex(
@@ -59,33 +59,35 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
59
59
  t >= 0 && l.value.fileList.splice(t, 1);
60
60
  });
61
61
  }
62
- function q(e) {
63
- if (r && r > 1 && c.length >= r)
64
- return clearTimeout(T), T = setTimeout(() => {
62
+ function $(e) {
63
+ if (i && i > 1 && p.length >= i)
64
+ return clearTimeout(N), N = setTimeout(() => {
65
65
  m.warning(
66
- i("ap.apUpload.maxUploadFiles", {
67
- maxCount: r
66
+ q || r("ap.apUpload.maxUploadFiles", {
67
+ maxCount: i
68
68
  })
69
69
  );
70
70
  }), v(e), !1;
71
- if (typeof A == "function") {
72
- if (A(e) === !1)
71
+ if (typeof _ == "function") {
72
+ if (_(e) === !1)
73
73
  return v(e), !1;
74
74
  } else {
75
- if (e.size > _ * 1024 * 1024)
75
+ if (e.size > U * 1024 * 1024)
76
76
  return m.warning(
77
- i("ap.apUpload.maxUploadFileSize", {
78
- maxSize: _
77
+ O || r("ap.apUpload.maxUploadFileSize", {
78
+ maxSize: U
79
79
  })
80
80
  ), v(e), !1;
81
- if (!ne(e, x))
82
- return m.warning(i("ap.apUpload.fileFormatNotSupported")), v(e), !1;
81
+ if (!le(e, h))
82
+ return m.warning(
83
+ D || r("ap.apUpload.fileFormatNotSupported")
84
+ ), v(e), !1;
83
85
  }
84
- r && r === 1 && (c = [], a.value = void 0), c.push(e);
86
+ i && i === 1 && (p = [], s.value = void 0), p.push(e);
85
87
  }
86
- async function D(e) {
87
- if (d.value++, typeof F == "function") {
88
- F({
88
+ async function j(e) {
89
+ if (d.value++, typeof A == "function") {
90
+ A({
89
91
  onProgress: (t) => {
90
92
  setTimeout(() => {
91
93
  e.onProgress({
@@ -94,7 +96,7 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
94
96
  });
95
97
  },
96
98
  onError: (t) => {
97
- m.warning(t || i("ap.apUpload.networkAnomaly")), setTimeout(() => {
99
+ m.warning(t || r("ap.apUpload.networkAnomaly")), setTimeout(() => {
98
100
  e.onError({
99
101
  name: t,
100
102
  message: t
@@ -104,10 +106,10 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
104
106
  onSuccess: (t) => {
105
107
  setTimeout(() => {
106
108
  e.onSuccess(t);
107
- }), a.value = [
108
- ...a.value || [],
109
- S(g, t, e.file.name)
110
- ], p.push({
109
+ }), s.value = [
110
+ ...s.value || [],
111
+ M(g, t, e.file.name)
112
+ ], c.push({
111
113
  uid: e.file.uid,
112
114
  path: t
113
115
  }), d.value--;
@@ -117,22 +119,22 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
117
119
  return;
118
120
  }
119
121
  try {
120
- const t = await te(O);
121
- e.file.oss = t, I({
122
+ const t = await ae(R);
123
+ e.file.oss = t, z({
122
124
  file: e.file,
123
- dirName: z,
125
+ dirName: I,
124
126
  oss: t,
125
127
  successCallBack(o) {
126
- e.onSuccess(o), a.value = [
127
- ...a.value || [],
128
- S(g, o, e.file.name)
129
- ], p.push({
128
+ e.onSuccess(o), s.value = [
129
+ ...s.value || [],
130
+ M(g, o, e.file.name)
131
+ ], c.push({
130
132
  uid: e.file.uid,
131
133
  path: o
132
134
  }), d.value--;
133
135
  },
134
136
  errorCallBack(o) {
135
- m.warning(o || i("ap.apUpload.networkAnomaly")), e.onError({
137
+ m.warning(o || r("ap.apUpload.networkAnomaly")), e.onError({
136
138
  name: o,
137
139
  message: o
138
140
  }), d.value--;
@@ -145,65 +147,65 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
145
147
  });
146
148
  } catch (t) {
147
149
  m.warning(
148
- typeof (t == null ? void 0 : t.message) == "string" ? t.message : i("ap.apUpload.networkAnomaly")
150
+ typeof (t == null ? void 0 : t.message) == "string" ? t.message : r("ap.apUpload.networkAnomaly")
149
151
  ), e.onError({
150
- name: (t == null ? void 0 : t.message) || i("ap.apUpload.networkAnomaly"),
151
- message: (t == null ? void 0 : t.message) || i("ap.apUpload.networkAnomaly")
152
+ name: (t == null ? void 0 : t.message) || r("ap.apUpload.networkAnomaly"),
153
+ message: (t == null ? void 0 : t.message) || r("ap.apUpload.networkAnomaly")
152
154
  }), d.value--;
153
155
  }
154
156
  }
155
- function M(e) {
157
+ function V(e) {
156
158
  var o;
157
159
  if (e.response) {
158
- if (Array.isArray(a.value)) {
159
- const u = p.findIndex((y) => y.uid === e.uid);
160
- u >= 0 && (a == null || a.value.splice(u, 1), p.splice(u, 1)), a.value.length === 0 && (a.value = void 0);
160
+ if (Array.isArray(s.value)) {
161
+ const u = c.findIndex((y) => y.uid === e.uid);
162
+ u >= 0 && (s == null || s.value.splice(u, 1), c.splice(u, 1)), s.value.length === 0 && (s.value = void 0);
161
163
  }
162
164
  } else
163
165
  (o = e == null ? void 0 : e.oss) == null || o.pauseUpload();
164
- const t = c.findIndex(
166
+ const t = p.findIndex(
165
167
  (u) => u.uid === e.uid
166
168
  );
167
- return c.splice(t, 1), Promise.resolve(!0);
169
+ return p.splice(t, 1), Promise.resolve(!0);
168
170
  }
169
- return (e, t) => (h(), k("div", {
170
- class: G({
171
- [s(U)()]: !0,
172
- [s(U)("admin")]: s(P) === "admin"
171
+ return (e, t) => (x(), C("div", {
172
+ class: K({
173
+ [n(E)()]: !0,
174
+ [n(E)("admin")]: n(B) === "admin"
173
175
  })
174
176
  }, [
175
- C(s(oe), {
177
+ k(n(ne), {
176
178
  ref_key: "uploadRef",
177
179
  ref: l,
178
- accept: s(x),
180
+ accept: n(h),
179
181
  multiple: "",
180
- maxCount: s(r),
182
+ maxCount: n(i),
181
183
  progress: {
182
184
  strokeWidth: 3,
183
185
  showInfo: !1,
184
186
  strokeColor: "#0070FF"
185
187
  },
186
- beforeUpload: q,
187
- customRequest: D,
188
- onRemove: M
188
+ beforeUpload: $,
189
+ customRequest: j,
190
+ onRemove: V
189
191
  }, {
190
- default: E(() => [
191
- L("div", ue, [
192
- C(s(ae), { class: "file-btn" }, {
193
- default: E(() => [
194
- C(s(se)),
195
- H(" " + b(s(R)), 1)
192
+ default: T(() => [
193
+ S("div", me, [
194
+ k(n(re), { class: "file-btn" }, {
195
+ default: T(() => [
196
+ k(n(ie)),
197
+ Q(" " + L(n(P)), 1)
196
198
  ]),
197
199
  _: 1
198
200
  }),
199
- L("div", {
201
+ S("div", {
200
202
  class: "sub-title",
201
- onClick: t[0] || (t[0] = J(() => {
203
+ onClick: t[0] || (t[0] = X(() => {
202
204
  }, ["stop"]))
203
205
  }, [
204
- typeof s(f) == "string" ? (h(), k("div", pe, b(s(f) || `${s(i)("ap.apUpload.supportExtension")}:${s(ie)(s(x))}`), 1)) : s(f) ? (h(), k("div", ce, [
205
- (h(), K(Q(s(f))))
206
- ])) : X("", !0)
206
+ typeof n(f) == "string" ? (x(), C("div", de, L(n(f) || `${n(r)("ap.apUpload.supportExtension")}:${n(ue)(n(h))}`), 1)) : n(f) ? (x(), C("div", fe, [
207
+ (x(), Y(Z(n(f))))
208
+ ])) : ee("", !0)
207
209
  ])
208
210
  ])
209
211
  ]),
@@ -213,5 +215,5 @@ const ue = { class: "multiple-file-context" }, pe = { key: 0 }, ce = { key: 1 },
213
215
  }
214
216
  });
215
217
  export {
216
- Ce as default
218
+ _e as default
217
219
  };