@duxweb/dvha-core 0.1.11 → 0.1.13
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/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/exportCsv.cjs +2 -0
- package/dist/cjs/hooks/importCsv.cjs +2 -0
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/hooks/upload/local.cjs +1 -0
- package/dist/cjs/hooks/upload/s3.cjs +1 -0
- package/dist/cjs/hooks/upload.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/esm/components/auth/can.js +7 -5
- package/dist/esm/directive/permission.js +4 -2
- package/dist/esm/hooks/exportCsv.js +55 -0
- package/dist/esm/hooks/importCsv.js +56 -0
- package/dist/esm/hooks/overlay.js +6 -4
- package/dist/esm/hooks/upload/local.js +31 -0
- package/dist/esm/hooks/upload/s3.js +72 -0
- package/dist/esm/hooks/upload.js +269 -0
- package/dist/esm/index.js +66 -56
- package/dist/esm/preset/dataProvider.js +67 -48
- package/dist/esm/provider/app.js +4 -2
- package/dist/types/hooks/data.d.ts +1 -1
- package/dist/types/hooks/export.d.ts +1 -2
- package/dist/types/hooks/exportCsv.d.ts +17 -0
- package/dist/types/hooks/import.d.ts +1 -1
- package/dist/types/hooks/importCsv.d.ts +26 -0
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/hooks/theme.d.ts +0 -4
- package/dist/types/hooks/upload/index.d.ts +3 -0
- package/dist/types/hooks/upload/local.d.ts +2 -0
- package/dist/types/hooks/upload/s3.d.ts +12 -0
- package/dist/types/hooks/upload/types.d.ts +14 -0
- package/dist/types/hooks/upload.d.ts +141 -0
- package/dist/types/types/data.d.ts +8 -0
- package/package.json +2 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { useFileDialog as R } from "@vueuse/core";
|
|
2
|
+
import { uniqueId as V } from "lodash-es";
|
|
3
|
+
import { ref as g, computed as v, watch as W } from "vue";
|
|
4
|
+
import { createLocalUploadDriver as X } from "./upload/local.js";
|
|
5
|
+
function ne(l) {
|
|
6
|
+
const w = g(!1), i = g([]), u = g(-1), d = g(/* @__PURE__ */ new Map()), A = l.driver || X(), $ = v(() => {
|
|
7
|
+
const { onProgress: e, onDataCallback: n, onCancel: a, onComplete: t, maxFileSize: c, maxFileCount: o, accept: s, multiple: r, autoUpload: f, options: U, onSuccess: P, onError: x, method: Y, driver: Z, ...Q } = l;
|
|
8
|
+
return Q;
|
|
9
|
+
}), I = v(() => l.method || "POST"), b = v(() => {
|
|
10
|
+
const e = i.value.length, n = i.value.reduce((o, s) => o + (s.filesize || 0), 0);
|
|
11
|
+
let a = 0, t = 0;
|
|
12
|
+
return i.value.forEach((o, s) => {
|
|
13
|
+
var r;
|
|
14
|
+
s < u.value ? a += o.filesize || 0 : s === u.value && (a += ((r = o.progress) == null ? void 0 : r.loaded) || 0);
|
|
15
|
+
}), n > 0 && (t = Math.round(a / n * 100)), {
|
|
16
|
+
index: u.value >= 0 ? u.value + 1 : 0,
|
|
17
|
+
totalFiles: e,
|
|
18
|
+
currentFile: i.value[u.value],
|
|
19
|
+
totalPercent: t,
|
|
20
|
+
totalLoaded: a,
|
|
21
|
+
totalSize: n
|
|
22
|
+
};
|
|
23
|
+
}), y = (e) => {
|
|
24
|
+
if (e === 0)
|
|
25
|
+
return "0 Bytes";
|
|
26
|
+
const n = 1024, a = ["Bytes", "KB", "MB", "GB"], t = Math.floor(Math.log(e) / Math.log(n));
|
|
27
|
+
return `${Number.parseFloat((e / n ** t).toFixed(2))} ${a[t]}`;
|
|
28
|
+
}, h = (e) => {
|
|
29
|
+
if (e === 0)
|
|
30
|
+
return "0 B/s";
|
|
31
|
+
const n = 1024, a = ["B/s", "KB/s", "MB/s", "GB/s"], t = Math.floor(Math.log(e) / Math.log(n));
|
|
32
|
+
return `${Number.parseFloat((e / n ** t).toFixed(2))} ${a[t]}`;
|
|
33
|
+
}, T = () => V("upload-"), k = async (e, n, a) => {
|
|
34
|
+
switch (n) {
|
|
35
|
+
case "file": {
|
|
36
|
+
if (!(e instanceof File))
|
|
37
|
+
throw new TypeError('Payload must be a File when type is "file"');
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
case "blob": {
|
|
41
|
+
if (!(e instanceof Blob))
|
|
42
|
+
throw new TypeError('Payload must be a Blob when type is "blob"');
|
|
43
|
+
return new File([e], "blob-file", { type: e.type });
|
|
44
|
+
}
|
|
45
|
+
case "base64": {
|
|
46
|
+
if (typeof e != "string")
|
|
47
|
+
throw new TypeError('Payload must be a string when type is "base64"');
|
|
48
|
+
const t = e.includes(",") ? e.split(",")[1] : e, c = e.includes(",") ? e.split(",")[0].split(":")[1].split(";")[0] : "application/octet-stream", o = atob(t), s = new Uint8Array(o.length);
|
|
49
|
+
for (let f = 0; f < o.length; f++)
|
|
50
|
+
s[f] = o.charCodeAt(f);
|
|
51
|
+
const r = new Blob([s], { type: c });
|
|
52
|
+
return new File([r], "base64-file", { type: c });
|
|
53
|
+
}
|
|
54
|
+
case "arrayBuffer": {
|
|
55
|
+
if (!(e instanceof ArrayBuffer))
|
|
56
|
+
throw new TypeError('Payload must be ArrayBuffer when type is "arrayBuffer"');
|
|
57
|
+
const t = new Blob([e]);
|
|
58
|
+
return new File([t], "array-buffer-file", { type: "application/octet-stream" });
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`Unsupported upload type: ${n}`);
|
|
62
|
+
}
|
|
63
|
+
}, z = (e) => {
|
|
64
|
+
if (l.maxFileSize && e.size > l.maxFileSize)
|
|
65
|
+
throw new Error(`File size cannot exceed ${y(l.maxFileSize)}`);
|
|
66
|
+
if (l.maxFileCount && i.value.length >= l.maxFileCount)
|
|
67
|
+
throw new Error(`File count cannot exceed ${l.maxFileCount}`);
|
|
68
|
+
}, D = async (e, n, a) => {
|
|
69
|
+
const t = await k(e, n);
|
|
70
|
+
z(t);
|
|
71
|
+
const c = {
|
|
72
|
+
id: T(),
|
|
73
|
+
file: t,
|
|
74
|
+
filename: t.name,
|
|
75
|
+
filesize: t.size,
|
|
76
|
+
filetype: t.type,
|
|
77
|
+
filesizeText: y(t.size),
|
|
78
|
+
status: "pending",
|
|
79
|
+
progress: {
|
|
80
|
+
loaded: 0,
|
|
81
|
+
total: t.size,
|
|
82
|
+
percent: 0,
|
|
83
|
+
speed: 0,
|
|
84
|
+
speedText: h(0),
|
|
85
|
+
remainingTime: 0,
|
|
86
|
+
uploadTime: 0
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return i.value.push(c), c;
|
|
90
|
+
}, m = (e, n) => {
|
|
91
|
+
const a = i.value.findIndex((t) => t.id === e);
|
|
92
|
+
a !== -1 && (i.value[a] = { ...i.value[a], ...n });
|
|
93
|
+
}, C = () => {
|
|
94
|
+
var n;
|
|
95
|
+
i.value.every((a) => a.status !== "uploading") && ((n = l.onComplete) == null || n.call(l, i.value));
|
|
96
|
+
}, F = (e) => {
|
|
97
|
+
var a;
|
|
98
|
+
const n = i.value.find((t) => t.id === e);
|
|
99
|
+
if (!n || n.status !== "pending" && n.status !== "uploading")
|
|
100
|
+
return !1;
|
|
101
|
+
if (n.status === "uploading") {
|
|
102
|
+
const t = d.value.get(e);
|
|
103
|
+
t && (t.abort(), d.value.delete(e));
|
|
104
|
+
}
|
|
105
|
+
return m(e, {
|
|
106
|
+
status: "cancelled"
|
|
107
|
+
}), (a = l.onCancel) == null || a.call(l, e), C(), !0;
|
|
108
|
+
}, G = (e) => {
|
|
109
|
+
e ? e.forEach((n) => F(n)) : i.value.forEach((n) => F(n.id));
|
|
110
|
+
}, K = async (e) => {
|
|
111
|
+
if (!e.file)
|
|
112
|
+
throw new Error("File not found");
|
|
113
|
+
z(e.file);
|
|
114
|
+
const n = new AbortController();
|
|
115
|
+
d.value.set(e.id, n);
|
|
116
|
+
const a = Date.now();
|
|
117
|
+
m(e.id, { status: "uploading" }), await A.upload(e.file, {
|
|
118
|
+
...$.value,
|
|
119
|
+
method: I.value,
|
|
120
|
+
signal: n.signal,
|
|
121
|
+
onUploadProgress: (t) => {
|
|
122
|
+
var x;
|
|
123
|
+
const s = (Date.now() - a) / 1e3, r = s > 0 ? t.loaded / s : 0, f = (t.total || 0) - t.loaded, U = r > 0 ? f / r : 0, P = {
|
|
124
|
+
loaded: t.loaded,
|
|
125
|
+
total: t.total,
|
|
126
|
+
percent: t.percent || 0,
|
|
127
|
+
speed: Math.round(r),
|
|
128
|
+
speedText: h(r),
|
|
129
|
+
uploadTime: Math.round(s),
|
|
130
|
+
remainingTime: Math.round(U)
|
|
131
|
+
};
|
|
132
|
+
m(e.id, {
|
|
133
|
+
status: "uploading",
|
|
134
|
+
progress: P
|
|
135
|
+
}), (x = l.onProgress) == null || x.call(l, b.value);
|
|
136
|
+
}
|
|
137
|
+
}).then((t) => {
|
|
138
|
+
var s, r;
|
|
139
|
+
if (e.status === "cancelled")
|
|
140
|
+
return;
|
|
141
|
+
const c = ((s = l.onDataCallback) == null ? void 0 : s.call(l, t, e)) || {}, o = Math.round((Date.now() - a) / 1e3);
|
|
142
|
+
m(e.id, {
|
|
143
|
+
status: "success",
|
|
144
|
+
data: t,
|
|
145
|
+
...c,
|
|
146
|
+
progress: {
|
|
147
|
+
...e.progress,
|
|
148
|
+
loaded: e.filesize || 0,
|
|
149
|
+
percent: 100,
|
|
150
|
+
speed: 0,
|
|
151
|
+
speedText: h(0),
|
|
152
|
+
uploadTime: o,
|
|
153
|
+
remainingTime: 0
|
|
154
|
+
}
|
|
155
|
+
}), d.value.delete(e.id), (r = l.onSuccess) == null || r.call(l, t);
|
|
156
|
+
}).catch((t) => {
|
|
157
|
+
if (!(t.message === "canceled" || e.status === "cancelled"))
|
|
158
|
+
throw m(e.id, {
|
|
159
|
+
status: "error",
|
|
160
|
+
error: t.message
|
|
161
|
+
}), d.value.delete(e.id), t;
|
|
162
|
+
}).finally(() => {
|
|
163
|
+
C();
|
|
164
|
+
});
|
|
165
|
+
}, B = async () => {
|
|
166
|
+
var n;
|
|
167
|
+
const e = i.value.filter((a) => a.status === "pending");
|
|
168
|
+
if (e.length !== 0) {
|
|
169
|
+
w.value = !0;
|
|
170
|
+
try {
|
|
171
|
+
for (let a = 0; a < e.length; a++) {
|
|
172
|
+
const t = e[a], c = i.value.findIndex((o) => o.id === t.id);
|
|
173
|
+
u.value = c, await K(t);
|
|
174
|
+
}
|
|
175
|
+
} catch (a) {
|
|
176
|
+
throw (n = l.onError) == null || n.call(l, {
|
|
177
|
+
status: (a == null ? void 0 : a.status) || 500,
|
|
178
|
+
message: (a == null ? void 0 : a.message) || "upload failed"
|
|
179
|
+
}), a;
|
|
180
|
+
} finally {
|
|
181
|
+
w.value = !1, u.value = -1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, E = async (e, n = "file") => {
|
|
185
|
+
var a;
|
|
186
|
+
try {
|
|
187
|
+
if (l.maxFileCount && i.value.length + e.length > l.maxFileCount)
|
|
188
|
+
throw new Error(`Adding ${e.length} files would exceed the maximum limit of ${l.maxFileCount}`);
|
|
189
|
+
for (const t of e)
|
|
190
|
+
await D(t, n);
|
|
191
|
+
} catch (t) {
|
|
192
|
+
throw (a = l.onError) == null || a.call(l, {
|
|
193
|
+
status: (t == null ? void 0 : t.status) || 400,
|
|
194
|
+
message: (t == null ? void 0 : t.message) || "Failed to add files"
|
|
195
|
+
}), t;
|
|
196
|
+
}
|
|
197
|
+
l.autoUpload && B();
|
|
198
|
+
}, L = (e) => {
|
|
199
|
+
const n = e.map((a) => H(a));
|
|
200
|
+
i.value.push(...n);
|
|
201
|
+
}, N = () => {
|
|
202
|
+
i.value.forEach((e) => {
|
|
203
|
+
F(e.id);
|
|
204
|
+
}), d.value.clear(), i.value = [], u.value = -1;
|
|
205
|
+
}, M = (e) => {
|
|
206
|
+
const n = i.value.find((t) => t.id === e);
|
|
207
|
+
if (n && n.status === "uploading") {
|
|
208
|
+
m(e, {
|
|
209
|
+
status: "cancelled"
|
|
210
|
+
});
|
|
211
|
+
const t = d.value.get(e);
|
|
212
|
+
if (!t)
|
|
213
|
+
return;
|
|
214
|
+
t.abort(), d.value.delete(e);
|
|
215
|
+
}
|
|
216
|
+
const a = i.value.findIndex((t) => t.id === e);
|
|
217
|
+
a !== -1 && i.value.splice(a, 1);
|
|
218
|
+
}, q = (e) => {
|
|
219
|
+
e ? e.forEach((n) => M(n)) : i.value.forEach((n) => M(n.id));
|
|
220
|
+
}, { files: O, open: j, reset: S } = R({
|
|
221
|
+
accept: l.accept,
|
|
222
|
+
multiple: l.multiple || !1
|
|
223
|
+
}), H = (e) => ({
|
|
224
|
+
id: T(),
|
|
225
|
+
...e,
|
|
226
|
+
filesizeText: e.filesize ? y(e.filesize) : void 0,
|
|
227
|
+
status: e.url ? "success" : "pending",
|
|
228
|
+
progress: {
|
|
229
|
+
loaded: 0,
|
|
230
|
+
total: e.filesize || 0,
|
|
231
|
+
percent: e.url ? 100 : 0,
|
|
232
|
+
speed: 0,
|
|
233
|
+
speedText: h(0),
|
|
234
|
+
remainingTime: 0,
|
|
235
|
+
uploadTime: 0
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
W(O, async (e) => {
|
|
239
|
+
if (e && e.length > 0) {
|
|
240
|
+
const n = Array.from(e);
|
|
241
|
+
S(), await E(n, "file").catch((a) => {
|
|
242
|
+
console.warn("Failed to add selected files:", a);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const J = v(() => i.value.filter((e) => e.status === "success").map((e) => ({
|
|
247
|
+
url: e.url,
|
|
248
|
+
filename: e.filename,
|
|
249
|
+
filesize: e.filesize,
|
|
250
|
+
filetype: e.filetype
|
|
251
|
+
})));
|
|
252
|
+
return {
|
|
253
|
+
isUploading: w,
|
|
254
|
+
uploadFiles: i,
|
|
255
|
+
dataFiles: J,
|
|
256
|
+
progress: b,
|
|
257
|
+
open: j,
|
|
258
|
+
trigger: B,
|
|
259
|
+
resetFiles: S,
|
|
260
|
+
clearFiles: N,
|
|
261
|
+
removeFiles: q,
|
|
262
|
+
addFiles: E,
|
|
263
|
+
addDataFiles: L,
|
|
264
|
+
cancelFiles: G
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export {
|
|
268
|
+
ne as useUpload
|
|
269
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
|
-
import { useCan as u, useCheck as s, useError as p, useForgotPassword as m, useGetAuth as x, useIsLogin as a, useLogin as f, useLogout as
|
|
2
|
+
import { useCan as u, useCheck as s, useError as p, useForgotPassword as m, useGetAuth as x, useIsLogin as a, useLogin as f, useLogout as i, useRegister as n, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
3
|
import { useConfig as D } from "./hooks/config.js";
|
|
4
|
-
import { useClient as C, useCreate as
|
|
5
|
-
import { useManage as
|
|
6
|
-
import { useMenu as
|
|
4
|
+
import { useClient as C, useCreate as g, useCreateMany as I, useCustom as L, useCustomMutation as M, useDelete as c, useDeleteMany as y, useInfiniteList as S, useInvalidate as T, useList as h, useMany as P, useOne as U, useUpdate as A, useUpdateMany as R } from "./hooks/data.js";
|
|
5
|
+
import { useManage as E } from "./hooks/manage.js";
|
|
6
|
+
import { useMenu as b } from "./hooks/menu.js";
|
|
7
7
|
import { useTheme as k } from "./hooks/theme.js";
|
|
8
8
|
import { useOverlay as V } from "./hooks/overlay.js";
|
|
9
9
|
import { useI18n as q } from "./hooks/i18n.js";
|
|
@@ -11,74 +11,84 @@ import { useSelect as B } from "./hooks/select.js";
|
|
|
11
11
|
import { useForm as J } from "./hooks/form.js";
|
|
12
12
|
import { useExport as N } from "./hooks/export.js";
|
|
13
13
|
import { useImport as W } from "./hooks/import.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
14
|
+
import { useExportCsv as Y } from "./hooks/exportCsv.js";
|
|
15
|
+
import { useImportCsv as _ } from "./hooks/importCsv.js";
|
|
16
|
+
import { useUpload as ee } from "./hooks/upload.js";
|
|
17
|
+
import { createLocalUploadDriver as oe } from "./hooks/upload/local.js";
|
|
18
|
+
import { createS3UploadDriver as ue } from "./hooks/upload/s3.js";
|
|
19
|
+
import { initRouter as pe } from "./router/route.js";
|
|
20
|
+
import { useAuthStore as xe } from "./stores/auth.js";
|
|
21
|
+
import { useRouteStore as fe } from "./stores/route.js";
|
|
22
|
+
import { useTabStore as ne } from "./stores/tab.js";
|
|
23
|
+
import { useManageStore as le } from "./stores/manage.js";
|
|
24
|
+
import { useI18nStore as ve } from "./stores/i18n.js";
|
|
25
|
+
import { DuxLogo as ge } from "./components/common/logo.js";
|
|
26
|
+
import { default as Le } from "./components/loader/iframe.js";
|
|
27
|
+
import { DuxOverlay as ce } from "./components/overlay/overlay.js";
|
|
28
|
+
import { DuxCan as Se } from "./components/auth/can.js";
|
|
29
|
+
import { arrayToTree as he, searchTree as Pe, treeToArr as Ue } from "./utils/tree.js";
|
|
30
|
+
import { DuxAppProvider as Re } from "./provider/app.js";
|
|
31
|
+
import { DuxTabRouterView as Ee } from "./provider/tab.js";
|
|
32
|
+
import { simpleAuthProvider as be } from "./preset/authProvider.js";
|
|
33
|
+
import { simpleDataProvider as ke } from "./preset/dataProvider.js";
|
|
34
|
+
import { i18nProvider as Ve } from "./preset/i18nProvider.js";
|
|
30
35
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
Re as DuxAppProvider,
|
|
37
|
+
Se as DuxCan,
|
|
38
|
+
Le as DuxLoaderIframe,
|
|
39
|
+
ge as DuxLogo,
|
|
40
|
+
ce as DuxOverlay,
|
|
41
|
+
Ee as DuxTabRouterView,
|
|
42
|
+
he as arrayToTree,
|
|
38
43
|
o as createDux,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
oe as createLocalUploadDriver,
|
|
45
|
+
ue as createS3UploadDriver,
|
|
46
|
+
Ve as i18nProvider,
|
|
47
|
+
pe as initRouter,
|
|
48
|
+
Pe as searchTree,
|
|
49
|
+
be as simpleAuthProvider,
|
|
50
|
+
ke as simpleDataProvider,
|
|
51
|
+
Ue as treeToArr,
|
|
52
|
+
xe as useAuthStore,
|
|
46
53
|
u as useCan,
|
|
47
54
|
s as useCheck,
|
|
48
55
|
C as useClient,
|
|
49
56
|
D as useConfig,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
g as useCreate,
|
|
58
|
+
I as useCreateMany,
|
|
59
|
+
L as useCustom,
|
|
60
|
+
M as useCustomMutation,
|
|
61
|
+
c as useDelete,
|
|
62
|
+
y as useDeleteMany,
|
|
56
63
|
p as useError,
|
|
57
64
|
N as useExport,
|
|
65
|
+
Y as useExportCsv,
|
|
58
66
|
m as useForgotPassword,
|
|
59
67
|
J as useForm,
|
|
60
68
|
x as useGetAuth,
|
|
61
69
|
q as useI18n,
|
|
62
|
-
|
|
70
|
+
ve as useI18nStore,
|
|
63
71
|
W as useImport,
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
_ as useImportCsv,
|
|
73
|
+
S as useInfiniteList,
|
|
74
|
+
T as useInvalidate,
|
|
66
75
|
a as useIsLogin,
|
|
67
|
-
|
|
76
|
+
h as useList,
|
|
68
77
|
f as useLogin,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
i as useLogout,
|
|
79
|
+
E as useManage,
|
|
80
|
+
le as useManageStore,
|
|
81
|
+
P as useMany,
|
|
82
|
+
b as useMenu,
|
|
83
|
+
U as useOne,
|
|
75
84
|
V as useOverlay,
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
n as useRegister,
|
|
86
|
+
fe as useRouteStore,
|
|
78
87
|
B as useSelect,
|
|
79
|
-
|
|
88
|
+
ne as useTabStore,
|
|
80
89
|
k as useTheme,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
d as useUpdatePassword
|
|
90
|
+
A as useUpdate,
|
|
91
|
+
R as useUpdateMany,
|
|
92
|
+
d as useUpdatePassword,
|
|
93
|
+
ee as useUpload
|
|
84
94
|
};
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { trimStart as
|
|
3
|
-
function
|
|
4
|
-
const r = (a) => a ? `${c.apiUrl}/${
|
|
1
|
+
import k from "axios";
|
|
2
|
+
import { trimStart as u } from "lodash-es";
|
|
3
|
+
function w(c) {
|
|
4
|
+
const r = (a) => a ? `${c.apiUrl}/${u(a || "", "/")}` : c.apiUrl;
|
|
5
5
|
return {
|
|
6
6
|
apiUrl: r,
|
|
7
|
-
getList: (a,
|
|
7
|
+
getList: (a, d, l) => {
|
|
8
8
|
const e = {};
|
|
9
|
-
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize),
|
|
9
|
+
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), k.get(r(a.path) || "", {
|
|
10
10
|
params: {
|
|
11
11
|
...e,
|
|
12
12
|
...a.filters,
|
|
13
13
|
...a.sorters
|
|
14
14
|
},
|
|
15
15
|
headers: {
|
|
16
|
-
Authorization:
|
|
16
|
+
Authorization: l == null ? void 0 : l.token
|
|
17
17
|
},
|
|
18
18
|
...a.meta
|
|
19
|
-
}).then((
|
|
20
|
-
throw c.errorCallback ? c.errorCallback(
|
|
19
|
+
}).then((t) => c.successCallback ? c.successCallback(t) : n(t)).catch((t) => {
|
|
20
|
+
throw c.errorCallback ? c.errorCallback(t) : b(t);
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
|
-
create: (a,
|
|
23
|
+
create: (a, d, l) => k.post(r(a.path) || "", a.data, {
|
|
24
24
|
headers: {
|
|
25
|
-
Authorization:
|
|
25
|
+
Authorization: l == null ? void 0 : l.token
|
|
26
26
|
},
|
|
27
27
|
...a.meta
|
|
28
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
28
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
29
29
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
30
30
|
}),
|
|
31
|
-
update: (a,
|
|
31
|
+
update: (a, d, l) => k.put(r(a.id ? `${a.path}/${a.id}` : a.path) || "", a.data, {
|
|
32
32
|
headers: {
|
|
33
|
-
Authorization:
|
|
33
|
+
Authorization: l == null ? void 0 : l.token
|
|
34
34
|
},
|
|
35
35
|
...a.meta
|
|
36
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
36
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
37
37
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
38
38
|
}),
|
|
39
|
-
deleteOne: (a,
|
|
39
|
+
deleteOne: (a, d, l) => k.delete(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
40
40
|
headers: {
|
|
41
|
-
Authorization:
|
|
41
|
+
Authorization: l == null ? void 0 : l.token
|
|
42
42
|
},
|
|
43
43
|
...a.meta
|
|
44
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
44
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
45
45
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
46
46
|
}),
|
|
47
|
-
getOne: (a,
|
|
47
|
+
getOne: (a, d, l) => k.get(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
48
48
|
headers: {
|
|
49
|
-
Authorization:
|
|
49
|
+
Authorization: l == null ? void 0 : l.token
|
|
50
50
|
},
|
|
51
51
|
...a.meta
|
|
52
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
52
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
53
53
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
54
54
|
}),
|
|
55
|
-
getMany: (a,
|
|
55
|
+
getMany: (a, d, l) => k.get(r(a.path) || "", {
|
|
56
56
|
params: {
|
|
57
57
|
ids: a.ids
|
|
58
58
|
},
|
|
59
59
|
headers: {
|
|
60
|
-
Authorization:
|
|
60
|
+
Authorization: l == null ? void 0 : l.token
|
|
61
61
|
},
|
|
62
62
|
...a.meta
|
|
63
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
63
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
64
64
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
65
65
|
}),
|
|
66
|
-
createMany: (a,
|
|
66
|
+
createMany: (a, d, l) => k.post(r(a.path) || "", a.data, {
|
|
67
67
|
headers: {
|
|
68
|
-
Authorization:
|
|
68
|
+
Authorization: l == null ? void 0 : l.token
|
|
69
69
|
},
|
|
70
70
|
...a.meta
|
|
71
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
71
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
72
72
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
73
73
|
}),
|
|
74
|
-
updateMany: (a,
|
|
74
|
+
updateMany: (a, d, l) => k.put(r(a.path) || "", {
|
|
75
75
|
ids: a.ids,
|
|
76
76
|
data: a.data
|
|
77
77
|
}, {
|
|
78
78
|
headers: {
|
|
79
|
-
Authorization:
|
|
79
|
+
Authorization: l == null ? void 0 : l.token
|
|
80
80
|
},
|
|
81
81
|
...a.meta
|
|
82
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
82
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
83
83
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
84
84
|
}),
|
|
85
|
-
deleteMany: (a,
|
|
85
|
+
deleteMany: (a, d, l) => k.delete(r(a.path) || "", {
|
|
86
86
|
params: {
|
|
87
87
|
ids: a.ids
|
|
88
88
|
},
|
|
89
89
|
headers: {
|
|
90
|
-
Authorization:
|
|
90
|
+
Authorization: l == null ? void 0 : l.token
|
|
91
91
|
},
|
|
92
92
|
...a.meta
|
|
93
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
93
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
94
94
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
95
95
|
}),
|
|
96
|
-
custom: (a,
|
|
96
|
+
custom: (a, d, l) => {
|
|
97
97
|
let e = {
|
|
98
98
|
...a.query
|
|
99
99
|
};
|
|
@@ -103,41 +103,60 @@ function g(c) {
|
|
|
103
103
|
}), a.filters && typeof a.filters == "object" && (e = {
|
|
104
104
|
...e,
|
|
105
105
|
...a.filters
|
|
106
|
-
}),
|
|
106
|
+
}), k.request({
|
|
107
107
|
url: r(a.path || ""),
|
|
108
108
|
method: a.method || "GET",
|
|
109
109
|
data: a.payload,
|
|
110
110
|
params: e,
|
|
111
|
+
signal: a.signal,
|
|
111
112
|
headers: {
|
|
112
|
-
Authorization:
|
|
113
|
+
Authorization: l == null ? void 0 : l.token,
|
|
113
114
|
...a.headers
|
|
114
115
|
},
|
|
116
|
+
onUploadProgress: (t) => {
|
|
117
|
+
var m;
|
|
118
|
+
const C = Math.round(t.loaded * 100 / (t.total || 1));
|
|
119
|
+
(m = a.onUploadProgress) == null || m.call(a, {
|
|
120
|
+
loaded: t.loaded,
|
|
121
|
+
total: t.total,
|
|
122
|
+
percent: C
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
onDownloadProgress: (t) => {
|
|
126
|
+
var m;
|
|
127
|
+
const C = Math.round(t.loaded * 100 / (t.total || 1));
|
|
128
|
+
(m = a.onDownloadProgress) == null || m.call(a, {
|
|
129
|
+
loaded: t.loaded,
|
|
130
|
+
total: t.total,
|
|
131
|
+
percent: C
|
|
132
|
+
});
|
|
133
|
+
},
|
|
115
134
|
...a.meta
|
|
116
|
-
}).then((
|
|
117
|
-
throw c.errorCallback ? c.errorCallback(
|
|
135
|
+
}).then((t) => c.successCallback ? c.successCallback(t) : n(t)).catch((t) => {
|
|
136
|
+
throw c.errorCallback ? c.errorCallback(t) : b(t);
|
|
118
137
|
});
|
|
119
138
|
}
|
|
120
139
|
};
|
|
121
140
|
}
|
|
122
|
-
function
|
|
123
|
-
var r, a,
|
|
141
|
+
function n(c) {
|
|
142
|
+
var r, a, d;
|
|
124
143
|
return {
|
|
125
144
|
message: (r = c.data) == null ? void 0 : r.message,
|
|
126
145
|
data: (a = c.data) == null ? void 0 : a.data,
|
|
127
|
-
meta: (
|
|
146
|
+
meta: (d = c.data) == null ? void 0 : d.meta,
|
|
128
147
|
raw: c.data
|
|
129
148
|
};
|
|
130
149
|
}
|
|
131
150
|
function b(c) {
|
|
132
|
-
var r, a, l, t;
|
|
151
|
+
var r, a, d, l, e, t, C, m, g, h;
|
|
133
152
|
return {
|
|
134
|
-
message: ((r = c.response.data) == null ? void 0 :
|
|
135
|
-
data: (
|
|
136
|
-
meta: (
|
|
137
|
-
status: ((
|
|
138
|
-
raw: c.response.data
|
|
153
|
+
message: ((a = (r = c.response) == null ? void 0 : r.data) == null ? void 0 : a.message) || (c == null ? void 0 : c.message),
|
|
154
|
+
data: (l = (d = c.response) == null ? void 0 : d.data) == null ? void 0 : l.data,
|
|
155
|
+
meta: (t = (e = c.response) == null ? void 0 : e.data) == null ? void 0 : t.meta,
|
|
156
|
+
status: ((m = (C = c.response) == null ? void 0 : C.data) == null ? void 0 : m.code) || ((g = c.response) == null ? void 0 : g.status) || 500,
|
|
157
|
+
raw: (h = c.response) == null ? void 0 : h.data
|
|
139
158
|
};
|
|
140
159
|
}
|
|
141
160
|
export {
|
|
142
|
-
|
|
161
|
+
w as simpleDataProvider
|
|
143
162
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -13,7 +13,9 @@ import { useManageStore as T } from "../stores/manage.js";
|
|
|
13
13
|
import { useI18nStore as W } from "../stores/i18n.js";
|
|
14
14
|
import "@vueuse/core";
|
|
15
15
|
import "clsx";
|
|
16
|
-
|
|
16
|
+
import "json-2-csv";
|
|
17
|
+
import "axios";
|
|
18
|
+
const le = /* @__PURE__ */ O({
|
|
17
19
|
name: "DuxAppProvider",
|
|
18
20
|
props: {},
|
|
19
21
|
setup(X, {
|
|
@@ -142,5 +144,5 @@ const he = /* @__PURE__ */ O({
|
|
|
142
144
|
}
|
|
143
145
|
});
|
|
144
146
|
export {
|
|
145
|
-
|
|
147
|
+
le as DuxAppProvider
|
|
146
148
|
};
|
|
@@ -1579,7 +1579,7 @@ interface IClientParams extends IDataProviderCustomOptions {
|
|
|
1579
1579
|
* Custom request client
|
|
1580
1580
|
*/
|
|
1581
1581
|
export declare function useClient(): {
|
|
1582
|
-
request: (params: IClientParams) =>
|
|
1582
|
+
request: (params: IClientParams) => Promise<IDataProviderResponse>;
|
|
1583
1583
|
};
|
|
1584
1584
|
export declare function useInvalidate(): {
|
|
1585
1585
|
invalidate: (path: string, providerName?: string) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InfiniteData } from '@tanstack/vue-query';
|
|
2
2
|
import type { IDataProviderResponse } from '../types';
|
|
3
3
|
import type { IInfiniteListParams } from './data';
|
|
4
|
-
interface IUseExportProps extends IInfiniteListParams {
|
|
4
|
+
export interface IUseExportProps extends IInfiniteListParams {
|
|
5
5
|
onSuccess?: (data: InfiniteData<IDataProviderResponse | undefined> | undefined) => void;
|
|
6
6
|
interval?: number;
|
|
7
7
|
maxPage?: number;
|
|
@@ -11,4 +11,3 @@ export declare function useExport(props: IUseExportProps): {
|
|
|
11
11
|
isLoading: import("vue").ComputedRef<boolean>;
|
|
12
12
|
trigger: () => Promise<void>;
|
|
13
13
|
};
|
|
14
|
-
export {};
|