@duxweb/dvha-core 1.0.23 → 1.0.24

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.
Files changed (85) hide show
  1. package/dist/cjs/components/auth/can.cjs +1 -1
  2. package/dist/cjs/components/loader/iframe.cjs +1 -1
  3. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  4. package/dist/cjs/components/loader/remote/render.cjs +1 -1
  5. package/dist/cjs/components/overlay/overlay.cjs +1 -1
  6. package/dist/cjs/components/status/exception.cjs +1 -1
  7. package/dist/cjs/directive/permission.cjs +1 -1
  8. package/dist/cjs/hooks/auth.cjs +1 -1
  9. package/dist/cjs/hooks/data.cjs +1 -1
  10. package/dist/cjs/hooks/export.cjs +1 -1
  11. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  12. package/dist/cjs/hooks/form.cjs +1 -1
  13. package/dist/cjs/hooks/formExtend.cjs +1 -1
  14. package/dist/cjs/hooks/i18n.cjs +1 -1
  15. package/dist/cjs/hooks/import.cjs +1 -1
  16. package/dist/cjs/hooks/importCsv.cjs +2 -2
  17. package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
  18. package/dist/cjs/hooks/json/vFor.cjs +1 -1
  19. package/dist/cjs/hooks/json/vOn.cjs +1 -1
  20. package/dist/cjs/hooks/json/vShow.cjs +1 -1
  21. package/dist/cjs/hooks/json.cjs +1 -1
  22. package/dist/cjs/hooks/list.cjs +1 -1
  23. package/dist/cjs/hooks/manage.cjs +1 -1
  24. package/dist/cjs/hooks/menu.cjs +1 -1
  25. package/dist/cjs/hooks/select.cjs +1 -1
  26. package/dist/cjs/hooks/theme.cjs +3 -3
  27. package/dist/cjs/hooks/tree.cjs +1 -1
  28. package/dist/cjs/hooks/upload/s3.cjs +1 -1
  29. package/dist/cjs/hooks/upload.cjs +1 -1
  30. package/dist/cjs/preset/authProvider.cjs +1 -1
  31. package/dist/cjs/preset/dataProvider.cjs +1 -1
  32. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  33. package/dist/cjs/provider/app.cjs +1 -1
  34. package/dist/cjs/router/route.cjs +1 -1
  35. package/dist/cjs/stores/auth.cjs +1 -1
  36. package/dist/cjs/stores/i18n.cjs +1 -1
  37. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  38. package/dist/cjs/stores/manage.cjs +1 -1
  39. package/dist/cjs/stores/route.cjs +1 -1
  40. package/dist/cjs/stores/tab.cjs +1 -1
  41. package/dist/cjs/stores/theme.cjs +1 -1
  42. package/dist/cjs/utils/tree.cjs +1 -1
  43. package/dist/esm/components/auth/can.js +8 -11
  44. package/dist/esm/components/loader/iframe.js +14 -17
  45. package/dist/esm/components/loader/remote/loader.js +103 -105
  46. package/dist/esm/components/loader/remote/render.js +10 -11
  47. package/dist/esm/components/overlay/overlay.js +7 -7
  48. package/dist/esm/components/status/exception.js +10 -13
  49. package/dist/esm/directive/permission.js +6 -7
  50. package/dist/esm/hooks/auth.js +73 -83
  51. package/dist/esm/hooks/data.js +290 -345
  52. package/dist/esm/hooks/export.js +16 -17
  53. package/dist/esm/hooks/exportCsv.js +26 -27
  54. package/dist/esm/hooks/form.js +49 -54
  55. package/dist/esm/hooks/formExtend.js +24 -25
  56. package/dist/esm/hooks/i18n.js +11 -29
  57. package/dist/esm/hooks/import.js +31 -32
  58. package/dist/esm/hooks/importCsv.js +24 -25
  59. package/dist/esm/hooks/json/utils/expressionParser.js +36 -42
  60. package/dist/esm/hooks/json/vFor.js +15 -16
  61. package/dist/esm/hooks/json/vOn.js +17 -18
  62. package/dist/esm/hooks/json/vShow.js +9 -10
  63. package/dist/esm/hooks/json.js +88 -94
  64. package/dist/esm/hooks/list.js +100 -127
  65. package/dist/esm/hooks/manage.js +13 -17
  66. package/dist/esm/hooks/menu.js +39 -52
  67. package/dist/esm/hooks/select.js +35 -40
  68. package/dist/esm/hooks/theme.js +127 -141
  69. package/dist/esm/hooks/tree.js +22 -28
  70. package/dist/esm/hooks/upload/s3.js +22 -23
  71. package/dist/esm/hooks/upload.js +152 -159
  72. package/dist/esm/preset/authProvider.js +63 -117
  73. package/dist/esm/preset/dataProvider.js +69 -76
  74. package/dist/esm/preset/i18nProvider.js +18 -18
  75. package/dist/esm/provider/app.js +74 -81
  76. package/dist/esm/router/route.js +16 -24
  77. package/dist/esm/stores/auth.js +17 -20
  78. package/dist/esm/stores/i18n.js +10 -10
  79. package/dist/esm/stores/jsonSchema.js +20 -23
  80. package/dist/esm/stores/manage.js +33 -33
  81. package/dist/esm/stores/route.js +38 -50
  82. package/dist/esm/stores/tab.js +38 -54
  83. package/dist/esm/stores/theme.js +28 -29
  84. package/dist/esm/utils/tree.js +23 -24
  85. package/package.json +1 -1
@@ -1,38 +1,37 @@
1
- import { useFileDialog as Q } from "@vueuse/core";
2
- import { uniqueId as R } from "lodash-es";
3
- import { ref as g, computed as v, watch as V } from "vue";
4
- import { createLocalUploadDriver as W } from "./upload/local.js";
1
+ import { useFileDialog as H } from "@vueuse/core";
2
+ import { uniqueId as J } from "lodash-es";
3
+ import { ref as g, computed as v, watch as Q } from "vue";
4
+ import { createLocalUploadDriver as R } from "./upload/local.js";
5
5
  function ne(l) {
6
6
  l = l || {};
7
- const w = g(!1), i = g([]), d = g(-1), f = g(/* @__PURE__ */ new Map()), $ = l.driver || W(), I = v(() => {
8
- const { onProgress: e, onDataCallback: a, onCancel: n, onComplete: t, maxFileSize: c, maxFileCount: r, accept: o, multiple: s, autoUpload: u, options: A, onSuccess: P, onError: b, method: Y, driver: Z, params: _, ...J } = l;
9
- return J;
10
- }), k = v(() => l.method || "POST"), T = v(() => {
11
- const e = i.value.length, a = i.value.reduce((r, o) => r + (o.filesize || 0), 0);
12
- let n = 0, t = 0;
13
- return i.value.forEach((r, o) => {
14
- var s;
15
- o < d.value ? n += r.filesize || 0 : o === d.value && (n += ((s = r.progress) == null ? void 0 : s.loaded) || 0);
16
- }), a > 0 && (t = Math.round(n / a * 100)), {
17
- index: d.value >= 0 ? d.value + 1 : 0,
7
+ const w = g(!1), o = g([]), c = g(-1), u = g(/* @__PURE__ */ new Map()), A = l.driver || R(), P = v(() => {
8
+ const { onProgress: e, onDataCallback: t, onCancel: n, onComplete: a, maxFileSize: s, maxFileCount: i, accept: r, multiple: d, autoUpload: f, options: U, onSuccess: S, onError: W, method: X, driver: Y, params: Z, ...j } = l;
9
+ return j;
10
+ }), $ = v(() => l.method || "POST"), x = v(() => {
11
+ const e = o.value.length, t = o.value.reduce((i, r) => i + (r.filesize || 0), 0);
12
+ let n = 0, a = 0;
13
+ return o.value.forEach((i, r) => {
14
+ r < c.value ? n += i.filesize || 0 : r === c.value && (n += i.progress?.loaded || 0);
15
+ }), t > 0 && (a = Math.round(n / t * 100)), {
16
+ index: c.value >= 0 ? c.value + 1 : 0,
18
17
  totalFiles: e,
19
- currentFile: i.value[d.value],
20
- totalPercent: t,
18
+ currentFile: o.value[c.value],
19
+ totalPercent: a,
21
20
  totalLoaded: n,
22
- totalSize: a
21
+ totalSize: t
23
22
  };
24
- }), F = (e) => {
23
+ }), p = (e) => {
25
24
  if (e === 0)
26
25
  return "0 Bytes";
27
- const a = 1024, n = ["Bytes", "KB", "MB", "GB"], t = Math.floor(Math.log(e) / Math.log(a));
28
- return `${Number.parseFloat((e / a ** t).toFixed(2))} ${n[t]}`;
26
+ const t = 1024, n = ["Bytes", "KB", "MB", "GB"], a = Math.floor(Math.log(e) / Math.log(t));
27
+ return `${Number.parseFloat((e / t ** a).toFixed(2))} ${n[a]}`;
29
28
  }, h = (e) => {
30
29
  if (e === 0)
31
30
  return "0 B/s";
32
- const a = 1024, n = ["B/s", "KB/s", "MB/s", "GB/s"], t = Math.floor(Math.log(e) / Math.log(a));
33
- return `${Number.parseFloat((e / a ** t).toFixed(2))} ${n[t]}`;
34
- }, z = () => R("upload-"), D = async (e, a, n) => {
35
- switch (a) {
31
+ const t = 1024, n = ["B/s", "KB/s", "MB/s", "GB/s"], a = Math.floor(Math.log(e) / Math.log(t));
32
+ return `${Number.parseFloat((e / t ** a).toFixed(2))} ${n[a]}`;
33
+ }, b = () => J("upload-"), I = async (e, t, n) => {
34
+ switch (t) {
36
35
  case "file": {
37
36
  if (!(e instanceof File))
38
37
  throw new TypeError('Payload must be a File when type is "file"');
@@ -46,40 +45,40 @@ function ne(l) {
46
45
  case "base64": {
47
46
  if (typeof e != "string")
48
47
  throw new TypeError('Payload must be a string when type is "base64"');
49
- const t = e.includes(",") ? e.split(",")[1] : e, c = e.includes(",") ? e.split(",")[0].split(":")[1].split(";")[0] : "application/octet-stream", r = atob(t), o = new Uint8Array(r.length);
50
- for (let u = 0; u < r.length; u++)
51
- o[u] = r.charCodeAt(u);
52
- const s = new Blob([o], { type: c });
53
- return new File([s], "base64-file", { type: c });
48
+ const a = e.includes(",") ? e.split(",")[1] : e, s = e.includes(",") ? e.split(",")[0].split(":")[1].split(";")[0] : "application/octet-stream", i = atob(a), r = new Uint8Array(i.length);
49
+ for (let f = 0; f < i.length; f++)
50
+ r[f] = i.charCodeAt(f);
51
+ const d = new Blob([r], { type: s });
52
+ return new File([d], "base64-file", { type: s });
54
53
  }
55
54
  case "arrayBuffer": {
56
55
  if (!(e instanceof ArrayBuffer))
57
56
  throw new TypeError('Payload must be ArrayBuffer when type is "arrayBuffer"');
58
- const t = new Blob([e]);
59
- return new File([t], "array-buffer-file", { type: "application/octet-stream" });
57
+ const a = new Blob([e]);
58
+ return new File([a], "array-buffer-file", { type: "application/octet-stream" });
60
59
  }
61
60
  default:
62
- throw new Error(`Unsupported upload type: ${a}`);
61
+ throw new Error(`Unsupported upload type: ${t}`);
63
62
  }
64
- }, C = (e) => {
63
+ }, T = (e) => {
65
64
  if (l.maxFileSize && e.size > l.maxFileSize)
66
- throw new Error(`File size cannot exceed ${F(l.maxFileSize)}`);
67
- if (l.maxFileCount && i.value.length >= l.maxFileCount)
65
+ throw new Error(`File size cannot exceed ${p(l.maxFileSize)}`);
66
+ if (l.maxFileCount && o.value.length >= l.maxFileCount)
68
67
  throw new Error(`File count cannot exceed ${l.maxFileCount}`);
69
- }, G = async (e, a, n) => {
70
- const t = await D(e, a);
71
- C(t);
72
- const c = {
73
- id: z(),
74
- file: t,
75
- filename: t.name,
76
- filesize: t.size,
77
- filetype: t.type,
78
- filesizeText: F(t.size),
68
+ }, k = async (e, t, n) => {
69
+ const a = await I(e, t);
70
+ T(a);
71
+ const s = {
72
+ id: b(),
73
+ file: a,
74
+ filename: a.name,
75
+ filesize: a.size,
76
+ filetype: a.type,
77
+ filesizeText: p(a.size),
79
78
  status: "pending",
80
79
  progress: {
81
80
  loaded: 0,
82
- total: t.size,
81
+ total: a.size,
83
82
  percent: 0,
84
83
  speed: 0,
85
84
  speedText: h(0),
@@ -87,150 +86,144 @@ function ne(l) {
87
86
  uploadTime: 0
88
87
  }
89
88
  };
90
- return i.value.push(c), c;
91
- }, m = (e, a) => {
92
- const n = i.value.findIndex((t) => t.id === e);
93
- n !== -1 && (i.value[n] = { ...i.value[n], ...a });
94
- }, E = () => {
95
- var a;
96
- i.value.every((n) => n.status !== "uploading") && ((a = l.onComplete) == null || a.call(l, i.value));
97
- }, y = (e) => {
98
- var n;
99
- const a = i.value.find((t) => t.id === e);
100
- if (!a || a.status !== "pending" && a.status !== "uploading")
89
+ return o.value.push(s), s;
90
+ }, m = (e, t) => {
91
+ const n = o.value.findIndex((a) => a.id === e);
92
+ n !== -1 && (o.value[n] = { ...o.value[n], ...t });
93
+ }, z = () => {
94
+ o.value.every((t) => t.status !== "uploading") && l.onComplete?.(o.value);
95
+ }, F = (e) => {
96
+ const t = o.value.find((n) => n.id === e);
97
+ if (!t || t.status !== "pending" && t.status !== "uploading")
101
98
  return !1;
102
- if (a.status === "uploading") {
103
- const t = f.value.get(e);
104
- t && (t.abort(), f.value.delete(e));
99
+ if (t.status === "uploading") {
100
+ const n = u.value.get(e);
101
+ n && (n.abort(), u.value.delete(e));
105
102
  }
106
103
  return m(e, {
107
104
  status: "cancelled"
108
- }), (n = l.onCancel) == null || n.call(l, e), E(), !0;
109
- }, K = (e) => {
110
- e ? e.forEach((a) => y(a)) : i.value.forEach((a) => y(a.id));
111
- }, L = async (e) => {
105
+ }), l.onCancel?.(e), z(), !0;
106
+ }, D = (e) => {
107
+ e ? e.forEach((t) => F(t)) : o.value.forEach((t) => F(t.id));
108
+ }, G = async (e) => {
112
109
  if (!e.file)
113
110
  throw new Error("File not found");
114
- C(e.file);
115
- const a = new AbortController();
116
- f.value.set(e.id, a);
111
+ T(e.file);
112
+ const t = new AbortController();
113
+ u.value.set(e.id, t);
117
114
  const n = Date.now();
118
- return m(e.id, { status: "uploading" }), $.upload(e.file, {
119
- ...I.value,
120
- method: k.value,
121
- signal: a.signal,
115
+ return m(e.id, { status: "uploading" }), A.upload(e.file, {
116
+ ...P.value,
117
+ method: $.value,
118
+ signal: t.signal,
122
119
  params: l.params,
123
- onUploadProgress: (t) => {
124
- var b;
125
- const o = (Date.now() - n) / 1e3, s = o > 0 ? t.loaded / o : 0, u = (t.total || 0) - t.loaded, A = s > 0 ? u / s : 0, P = {
126
- loaded: t.loaded,
127
- total: t.total,
128
- percent: t.percent || 0,
129
- speed: Math.round(s),
130
- speedText: h(s),
131
- uploadTime: Math.round(o),
132
- remainingTime: Math.round(A)
120
+ onUploadProgress: (a) => {
121
+ const r = (Date.now() - n) / 1e3, d = r > 0 ? a.loaded / r : 0, f = (a.total || 0) - a.loaded, U = d > 0 ? f / d : 0, S = {
122
+ loaded: a.loaded,
123
+ total: a.total,
124
+ percent: a.percent || 0,
125
+ speed: Math.round(d),
126
+ speedText: h(d),
127
+ uploadTime: Math.round(r),
128
+ remainingTime: Math.round(U)
133
129
  };
134
130
  m(e.id, {
135
131
  status: "uploading",
136
- progress: P
137
- }), (b = l.onProgress) == null || b.call(l, T.value);
132
+ progress: S
133
+ }), l.onProgress?.(x.value);
138
134
  }
139
- }).then((t) => {
140
- var s, u;
135
+ }).then((a) => {
141
136
  if (e.status === "cancelled")
142
137
  throw new Error("Upload cancelled");
143
- const c = ((s = l.onDataCallback) == null ? void 0 : s.call(l, t, e)) || t.data, r = Math.round((Date.now() - n) / 1e3), o = {
138
+ const s = l.onDataCallback?.(a, e) || a.data, i = Math.round((Date.now() - n) / 1e3), r = {
144
139
  ...e,
145
140
  status: "success",
146
- data: t,
147
- ...c,
141
+ data: a,
142
+ ...s,
148
143
  progress: {
149
144
  ...e.progress,
150
145
  loaded: e.filesize || 0,
151
146
  percent: 100,
152
147
  speed: 0,
153
148
  speedText: h(0),
154
- uploadTime: r,
149
+ uploadTime: i,
155
150
  remainingTime: 0
156
151
  }
157
152
  };
158
- return m(e.id, o), f.value.delete(e.id), (u = l.onSuccess) == null || u.call(l, t), o;
159
- }).catch((t) => {
160
- throw t.message === "canceled" || e.status === "cancelled" ? new Error("Upload cancelled") : (m(e.id, {
153
+ return m(e.id, r), u.value.delete(e.id), l.onSuccess?.(a), r;
154
+ }).catch((a) => {
155
+ throw a.message === "canceled" || e.status === "cancelled" ? new Error("Upload cancelled") : (m(e.id, {
161
156
  status: "error",
162
- error: t.message
163
- }), f.value.delete(e.id), t);
157
+ error: a.message
158
+ }), u.value.delete(e.id), a);
164
159
  }).finally(() => {
165
- E();
160
+ z();
166
161
  });
167
- }, B = async () => {
168
- var a;
169
- const e = i.value.filter((n) => n.status === "pending");
162
+ }, C = async () => {
163
+ const e = o.value.filter((t) => t.status === "pending");
170
164
  if (e.length === 0)
171
165
  return [];
172
166
  w.value = !0;
173
167
  try {
174
- const n = [];
175
- for (let t = 0; t < e.length; t++) {
176
- const c = e[t], r = i.value.findIndex((s) => s.id === c.id);
177
- d.value = r;
178
- const o = await L(c);
179
- n.push(o);
168
+ const t = [];
169
+ for (let n = 0; n < e.length; n++) {
170
+ const a = e[n], s = o.value.findIndex((r) => r.id === a.id);
171
+ c.value = s;
172
+ const i = await G(a);
173
+ t.push(i);
180
174
  }
181
- return n;
182
- } catch (n) {
183
- throw (a = l.onError) == null || a.call(l, {
184
- status: (n == null ? void 0 : n.status) || 500,
185
- message: (n == null ? void 0 : n.message) || "upload failed"
186
- }), n;
175
+ return t;
176
+ } catch (t) {
177
+ throw l.onError?.({
178
+ status: t?.status || 500,
179
+ message: t?.message || "upload failed"
180
+ }), t;
187
181
  } finally {
188
- w.value = !1, d.value = -1;
182
+ w.value = !1, c.value = -1;
189
183
  }
190
- }, x = () => {
191
- i.value.forEach((e) => {
192
- y(e.id);
193
- }), f.value.clear(), i.value = [], d.value = -1;
194
- }, M = async (e, a = "file") => {
195
- var n;
184
+ }, y = () => {
185
+ o.value.forEach((e) => {
186
+ F(e.id);
187
+ }), u.value.clear(), o.value = [], c.value = -1;
188
+ }, E = async (e, t = "file") => {
196
189
  try {
197
190
  if (!l.multiple && e.length > 1)
198
191
  throw new Error("Single file mode: only one file can be selected");
199
- if (!l.multiple && i.value.length > 0 && x(), l.maxFileCount && i.value.length + e.length > l.maxFileCount)
192
+ if (!l.multiple && o.value.length > 0 && y(), l.maxFileCount && o.value.length + e.length > l.maxFileCount)
200
193
  throw new Error(`Adding ${e.length} files would exceed the maximum limit of ${l.maxFileCount}`);
201
- for (const t of e)
202
- await G(t, a);
203
- } catch (t) {
204
- throw (n = l.onError) == null || n.call(l, {
205
- status: (t == null ? void 0 : t.status) || 400,
206
- message: (t == null ? void 0 : t.message) || "Failed to add files"
207
- }), t;
194
+ for (const n of e)
195
+ await k(n, t);
196
+ } catch (n) {
197
+ throw l.onError?.({
198
+ status: n?.status || 400,
199
+ message: n?.message || "Failed to add files"
200
+ }), n;
208
201
  }
209
- l.autoUpload && B().catch((t) => {
210
- console.warn("Auto upload failed:", t);
202
+ l.autoUpload && C().catch((n) => {
203
+ console.warn("Auto upload failed:", n);
211
204
  });
212
- }, U = (e) => {
213
- const a = i.value.find((t) => t.id === e);
214
- if (a && a.status === "uploading") {
205
+ }, B = (e) => {
206
+ const t = o.value.find((a) => a.id === e);
207
+ if (t && t.status === "uploading") {
215
208
  m(e, {
216
209
  status: "cancelled"
217
210
  });
218
- const t = f.value.get(e);
219
- if (!t)
211
+ const a = u.value.get(e);
212
+ if (!a)
220
213
  return;
221
- t.abort(), f.value.delete(e);
214
+ a.abort(), u.value.delete(e);
222
215
  }
223
- const n = i.value.findIndex((t) => t.id === e);
224
- n !== -1 && i.value.splice(n, 1);
225
- }, N = (e) => {
226
- e ? e.forEach((a) => U(a)) : i.value.forEach((a) => U(a.id));
227
- }, { files: q, open: O, reset: S } = Q({
216
+ const n = o.value.findIndex((a) => a.id === e);
217
+ n !== -1 && o.value.splice(n, 1);
218
+ }, K = (e) => {
219
+ e ? e.forEach((t) => B(t)) : o.value.forEach((t) => B(t.id));
220
+ }, { files: L, open: N, reset: M } = H({
228
221
  accept: l.accept,
229
222
  multiple: l.multiple || !1
230
- }), j = (e) => ({
231
- id: z(),
223
+ }), q = (e) => ({
224
+ id: b(),
232
225
  ...e,
233
- filesizeText: e.filesize ? F(e.filesize) : void 0,
226
+ filesizeText: e.filesize ? p(e.filesize) : void 0,
234
227
  status: e.url ? "success" : "pending",
235
228
  progress: {
236
229
  loaded: 0,
@@ -242,15 +235,15 @@ function ne(l) {
242
235
  uploadTime: 0
243
236
  }
244
237
  });
245
- V(q, async (e) => {
238
+ Q(L, async (e) => {
246
239
  if (e && e.length > 0) {
247
- const a = Array.from(e);
248
- S(), await M(a, "file").catch((n) => {
240
+ const t = Array.from(e);
241
+ M(), await E(t, "file").catch((n) => {
249
242
  console.warn("Failed to add selected files:", n);
250
243
  });
251
244
  }
252
245
  });
253
- const H = v(() => i.value.filter((e) => e.status === "success").map((e) => ({
246
+ const O = v(() => o.value.filter((e) => e.status === "success").map((e) => ({
254
247
  url: e.url,
255
248
  filename: e.filename,
256
249
  filesize: e.filesize,
@@ -258,21 +251,21 @@ function ne(l) {
258
251
  })));
259
252
  return {
260
253
  isUploading: w,
261
- uploadFiles: i,
262
- dataFiles: H,
263
- progress: T,
264
- open: O,
265
- trigger: B,
266
- resetFiles: S,
267
- clearFiles: x,
268
- removeFiles: N,
269
- addFiles: M,
254
+ uploadFiles: o,
255
+ dataFiles: O,
256
+ progress: x,
257
+ open: N,
258
+ trigger: C,
259
+ resetFiles: M,
260
+ clearFiles: y,
261
+ removeFiles: K,
262
+ addFiles: E,
270
263
  addDataFiles: (e) => {
271
- !l.multiple && i.value.length > 0 && x();
272
- const a = e.map((n) => j(n));
273
- i.value.push(...a);
264
+ !l.multiple && o.value.length > 0 && y();
265
+ const t = e.map((n) => q(n));
266
+ o.value.push(...t);
274
267
  },
275
- cancelFiles: K
268
+ cancelFiles: D
276
269
  };
277
270
  }
278
271
  export {
@@ -1,123 +1,69 @@
1
- import g from "axios";
2
- function m(t) {
1
+ import i from "axios";
2
+ function o(a) {
3
3
  return {
4
- login: async (n, c) => {
5
- var d;
6
- return await g.post(c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.login) || "/login", t == null ? void 0 : t.dataProviderName), n).then((e) => {
7
- var i, a, s;
8
- return {
9
- success: !0,
10
- message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
11
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
12
- data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
13
- };
14
- }).catch((e) => {
15
- var i, a;
16
- return {
17
- success: !1,
18
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
19
- };
20
- });
4
+ login: async (s, r) => await i.post(r.getApiUrl(a?.apiPath?.login || "/login", a?.dataProviderName), s).then((e) => ({
5
+ success: !0,
6
+ message: e?.data?.message,
7
+ redirectTo: a?.routePath?.index || "/",
8
+ data: e?.data?.data
9
+ })).catch((e) => ({
10
+ success: !1,
11
+ message: e?.response?.data?.message || e?.message
12
+ })),
13
+ check: async (s, r, e) => await i.get(r?.getApiUrl(a?.apiPath?.check || "/check", a?.dataProviderName) || "", {
14
+ headers: {
15
+ Authorization: e?.token || ""
16
+ }
17
+ }).then((t) => ({
18
+ success: !0,
19
+ logout: !1,
20
+ message: t?.data?.message,
21
+ data: t?.data?.data
22
+ })).catch((t) => ({
23
+ success: !1,
24
+ logout: !0,
25
+ message: t?.response?.data?.message || t?.message
26
+ })),
27
+ onError: async (s) => s?.status === 401 ? {
28
+ logout: !0,
29
+ redirectTo: a?.routePath?.login || "/login",
30
+ error: s
31
+ } : {
32
+ logout: !1,
33
+ error: s
21
34
  },
22
- check: async (n, c, d) => {
23
- var e;
24
- return await g.get((c == null ? void 0 : c.getApiUrl(((e = t == null ? void 0 : t.apiPath) == null ? void 0 : e.check) || "/check", t == null ? void 0 : t.dataProviderName)) || "", {
25
- headers: {
26
- Authorization: (d == null ? void 0 : d.token) || ""
27
- }
28
- }).then((i) => {
29
- var a, s;
30
- return {
31
- success: !0,
32
- logout: !1,
33
- message: (a = i == null ? void 0 : i.data) == null ? void 0 : a.message,
34
- data: (s = i == null ? void 0 : i.data) == null ? void 0 : s.data
35
- };
36
- }).catch((i) => {
37
- var a, s;
38
- return {
39
- success: !1,
40
- logout: !0,
41
- message: ((s = (a = i == null ? void 0 : i.response) == null ? void 0 : a.data) == null ? void 0 : s.message) || (i == null ? void 0 : i.message)
42
- };
43
- });
44
- },
45
- onError: async (n) => {
46
- var c;
47
- return (n == null ? void 0 : n.status) === 401 ? {
48
- logout: !0,
49
- redirectTo: ((c = t == null ? void 0 : t.routePath) == null ? void 0 : c.login) || "/login",
50
- error: n
51
- } : {
52
- logout: !1,
53
- error: n
54
- };
55
- },
56
- logout: async () => {
57
- var n;
58
- return {
59
- success: !0,
60
- redirectTo: ((n = t == null ? void 0 : t.routePath) == null ? void 0 : n.login) || "/login"
61
- };
62
- },
63
- register: async (n, c) => {
64
- var d;
65
- return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.register) || "/register", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
66
- var i, a, s;
67
- return {
68
- success: !0,
69
- message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
70
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
71
- data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
72
- };
73
- }).catch((e) => {
74
- var i, a;
75
- return {
76
- success: !1,
77
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
78
- };
79
- });
80
- },
81
- forgotPassword: async (n, c) => {
82
- var d;
83
- return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.forgotPassword) || "/forgot-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
84
- var i, a;
85
- return {
86
- success: !0,
87
- message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
88
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
89
- };
90
- }).catch((e) => {
91
- var i, a;
92
- return {
93
- success: !1,
94
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
95
- };
96
- });
97
- },
98
- updatePassword: async (n, c) => {
99
- var d;
100
- return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.updatePassword) || "/update-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
101
- var i, a;
102
- return {
103
- success: !0,
104
- message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
105
- redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
106
- };
107
- }).catch((e) => {
108
- var i, a;
109
- return {
110
- success: !1,
111
- message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
112
- };
113
- });
114
- },
115
- can: (n, c, d, e) => {
116
- var i, a;
117
- return !(e != null && e.permission) || Array.isArray(e == null ? void 0 : e.permission) && ((i = e == null ? void 0 : e.permission) == null ? void 0 : i.length) === 0 || typeof (e == null ? void 0 : e.permission) == "object" && Object.keys(e == null ? void 0 : e.permission).length === 0 ? !0 : !(Array.isArray(e == null ? void 0 : e.permission) && !((a = e == null ? void 0 : e.permission) != null && a.includes(n)) || typeof (e == null ? void 0 : e.permission) == "object" && (e == null ? void 0 : e.permission[n]) === !1);
118
- }
35
+ logout: async () => ({
36
+ success: !0,
37
+ redirectTo: a?.routePath?.login || "/login"
38
+ }),
39
+ register: async (s, r) => await i.post(r?.getApiUrl(a?.apiPath?.register || "/register", a?.dataProviderName) || "", s).then((e) => ({
40
+ success: !0,
41
+ message: e?.data?.message,
42
+ redirectTo: a?.routePath?.index || "/",
43
+ data: e?.data?.data
44
+ })).catch((e) => ({
45
+ success: !1,
46
+ message: e?.response?.data?.message || e?.message
47
+ })),
48
+ forgotPassword: async (s, r) => await i.post(r?.getApiUrl(a?.apiPath?.forgotPassword || "/forgot-password", a?.dataProviderName) || "", s).then((e) => ({
49
+ success: !0,
50
+ message: e?.data?.message,
51
+ redirectTo: a?.routePath?.login || "/login"
52
+ })).catch((e) => ({
53
+ success: !1,
54
+ message: e?.response?.data?.message || e?.message
55
+ })),
56
+ updatePassword: async (s, r) => await i.post(r?.getApiUrl(a?.apiPath?.updatePassword || "/update-password", a?.dataProviderName) || "", s).then((e) => ({
57
+ success: !0,
58
+ message: e?.data?.message,
59
+ redirectTo: a?.routePath?.login || "/login"
60
+ })).catch((e) => ({
61
+ success: !1,
62
+ message: e?.response?.data?.message || e?.message
63
+ })),
64
+ can: (s, r, e, t) => !t?.permission || Array.isArray(t?.permission) && t?.permission?.length === 0 || typeof t?.permission == "object" && Object.keys(t?.permission).length === 0 ? !0 : !(Array.isArray(t?.permission) && !t?.permission?.includes(s) || typeof t?.permission == "object" && t?.permission[s] === !1)
119
65
  };
120
66
  }
121
67
  export {
122
- m as simpleAuthProvider
68
+ o as simpleAuthProvider
123
69
  };