@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.
- package/dist/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/remote/loader.cjs +1 -1
- package/dist/cjs/components/loader/remote/render.cjs +1 -1
- package/dist/cjs/components/overlay/overlay.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/exportCsv.cjs +2 -2
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -1
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/import.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +2 -2
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
- package/dist/cjs/hooks/json/vFor.cjs +1 -1
- package/dist/cjs/hooks/json/vOn.cjs +1 -1
- package/dist/cjs/hooks/json/vShow.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/cjs/hooks/list.cjs +1 -1
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +3 -3
- package/dist/cjs/hooks/tree.cjs +1 -1
- package/dist/cjs/hooks/upload/s3.cjs +1 -1
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/router/route.cjs +1 -1
- package/dist/cjs/stores/auth.cjs +1 -1
- package/dist/cjs/stores/i18n.cjs +1 -1
- package/dist/cjs/stores/jsonSchema.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/route.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/tree.cjs +1 -1
- package/dist/esm/components/auth/can.js +8 -11
- package/dist/esm/components/loader/iframe.js +14 -17
- package/dist/esm/components/loader/remote/loader.js +103 -105
- package/dist/esm/components/loader/remote/render.js +10 -11
- package/dist/esm/components/overlay/overlay.js +7 -7
- package/dist/esm/components/status/exception.js +10 -13
- package/dist/esm/directive/permission.js +6 -7
- package/dist/esm/hooks/auth.js +73 -83
- package/dist/esm/hooks/data.js +290 -345
- package/dist/esm/hooks/export.js +16 -17
- package/dist/esm/hooks/exportCsv.js +26 -27
- package/dist/esm/hooks/form.js +49 -54
- package/dist/esm/hooks/formExtend.js +24 -25
- package/dist/esm/hooks/i18n.js +11 -29
- package/dist/esm/hooks/import.js +31 -32
- package/dist/esm/hooks/importCsv.js +24 -25
- package/dist/esm/hooks/json/utils/expressionParser.js +36 -42
- package/dist/esm/hooks/json/vFor.js +15 -16
- package/dist/esm/hooks/json/vOn.js +17 -18
- package/dist/esm/hooks/json/vShow.js +9 -10
- package/dist/esm/hooks/json.js +88 -94
- package/dist/esm/hooks/list.js +100 -127
- package/dist/esm/hooks/manage.js +13 -17
- package/dist/esm/hooks/menu.js +39 -52
- package/dist/esm/hooks/select.js +35 -40
- package/dist/esm/hooks/theme.js +127 -141
- package/dist/esm/hooks/tree.js +22 -28
- package/dist/esm/hooks/upload/s3.js +22 -23
- package/dist/esm/hooks/upload.js +152 -159
- package/dist/esm/preset/authProvider.js +63 -117
- package/dist/esm/preset/dataProvider.js +69 -76
- package/dist/esm/preset/i18nProvider.js +18 -18
- package/dist/esm/provider/app.js +74 -81
- package/dist/esm/router/route.js +16 -24
- package/dist/esm/stores/auth.js +17 -20
- package/dist/esm/stores/i18n.js +10 -10
- package/dist/esm/stores/jsonSchema.js +20 -23
- package/dist/esm/stores/manage.js +33 -33
- package/dist/esm/stores/route.js +38 -50
- package/dist/esm/stores/tab.js +38 -54
- package/dist/esm/stores/theme.js +28 -29
- package/dist/esm/utils/tree.js +23 -24
- package/package.json +1 -1
package/dist/esm/hooks/upload.js
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { useFileDialog as
|
|
2
|
-
import { uniqueId as
|
|
3
|
-
import { ref as g, computed as v, watch as
|
|
4
|
-
import { createLocalUploadDriver as
|
|
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),
|
|
8
|
-
const { onProgress: e, onDataCallback:
|
|
9
|
-
return
|
|
10
|
-
}),
|
|
11
|
-
const e =
|
|
12
|
-
let n = 0,
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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:
|
|
20
|
-
totalPercent:
|
|
18
|
+
currentFile: o.value[c.value],
|
|
19
|
+
totalPercent: a,
|
|
21
20
|
totalLoaded: n,
|
|
22
|
-
totalSize:
|
|
21
|
+
totalSize: t
|
|
23
22
|
};
|
|
24
|
-
}),
|
|
23
|
+
}), p = (e) => {
|
|
25
24
|
if (e === 0)
|
|
26
25
|
return "0 Bytes";
|
|
27
|
-
const
|
|
28
|
-
return `${Number.parseFloat((e /
|
|
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
|
|
33
|
-
return `${Number.parseFloat((e /
|
|
34
|
-
},
|
|
35
|
-
switch (
|
|
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
|
|
50
|
-
for (let
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
return new File([
|
|
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
|
|
59
|
-
return new File([
|
|
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: ${
|
|
61
|
+
throw new Error(`Unsupported upload type: ${t}`);
|
|
63
62
|
}
|
|
64
|
-
},
|
|
63
|
+
}, T = (e) => {
|
|
65
64
|
if (l.maxFileSize && e.size > l.maxFileSize)
|
|
66
|
-
throw new Error(`File size cannot exceed ${
|
|
67
|
-
if (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
|
-
},
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
id:
|
|
74
|
-
file:
|
|
75
|
-
filename:
|
|
76
|
-
filesize:
|
|
77
|
-
filetype:
|
|
78
|
-
filesizeText:
|
|
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:
|
|
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
|
|
91
|
-
}, m = (e,
|
|
92
|
-
const n =
|
|
93
|
-
n !== -1 && (
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 (
|
|
103
|
-
const
|
|
104
|
-
|
|
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
|
-
}),
|
|
109
|
-
},
|
|
110
|
-
e ? e.forEach((
|
|
111
|
-
},
|
|
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
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
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" }),
|
|
119
|
-
...
|
|
120
|
-
method:
|
|
121
|
-
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: (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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:
|
|
137
|
-
}),
|
|
132
|
+
progress: S
|
|
133
|
+
}), l.onProgress?.(x.value);
|
|
138
134
|
}
|
|
139
|
-
}).then((
|
|
140
|
-
var s, u;
|
|
135
|
+
}).then((a) => {
|
|
141
136
|
if (e.status === "cancelled")
|
|
142
137
|
throw new Error("Upload cancelled");
|
|
143
|
-
const
|
|
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:
|
|
147
|
-
...
|
|
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:
|
|
149
|
+
uploadTime: i,
|
|
155
150
|
remainingTime: 0
|
|
156
151
|
}
|
|
157
152
|
};
|
|
158
|
-
return m(e.id,
|
|
159
|
-
}).catch((
|
|
160
|
-
throw
|
|
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:
|
|
163
|
-
}),
|
|
157
|
+
error: a.message
|
|
158
|
+
}), u.value.delete(e.id), a);
|
|
164
159
|
}).finally(() => {
|
|
165
|
-
|
|
160
|
+
z();
|
|
166
161
|
});
|
|
167
|
-
},
|
|
168
|
-
|
|
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
|
|
175
|
-
for (let
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
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
|
|
182
|
-
} catch (
|
|
183
|
-
throw
|
|
184
|
-
status:
|
|
185
|
-
message:
|
|
186
|
-
}),
|
|
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,
|
|
182
|
+
w.value = !1, c.value = -1;
|
|
189
183
|
}
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}),
|
|
194
|
-
},
|
|
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 &&
|
|
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
|
|
202
|
-
await
|
|
203
|
-
} catch (
|
|
204
|
-
throw
|
|
205
|
-
status:
|
|
206
|
-
message:
|
|
207
|
-
}),
|
|
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 &&
|
|
210
|
-
console.warn("Auto upload failed:",
|
|
202
|
+
l.autoUpload && C().catch((n) => {
|
|
203
|
+
console.warn("Auto upload failed:", n);
|
|
211
204
|
});
|
|
212
|
-
},
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
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
|
|
219
|
-
if (!
|
|
211
|
+
const a = u.value.get(e);
|
|
212
|
+
if (!a)
|
|
220
213
|
return;
|
|
221
|
-
|
|
214
|
+
a.abort(), u.value.delete(e);
|
|
222
215
|
}
|
|
223
|
-
const n =
|
|
224
|
-
n !== -1 &&
|
|
225
|
-
},
|
|
226
|
-
e ? e.forEach((
|
|
227
|
-
}, { files:
|
|
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
|
-
}),
|
|
231
|
-
id:
|
|
223
|
+
}), q = (e) => ({
|
|
224
|
+
id: b(),
|
|
232
225
|
...e,
|
|
233
|
-
filesizeText: e.filesize ?
|
|
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
|
-
|
|
238
|
+
Q(L, async (e) => {
|
|
246
239
|
if (e && e.length > 0) {
|
|
247
|
-
const
|
|
248
|
-
|
|
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
|
|
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:
|
|
262
|
-
dataFiles:
|
|
263
|
-
progress:
|
|
264
|
-
open:
|
|
265
|
-
trigger:
|
|
266
|
-
resetFiles:
|
|
267
|
-
clearFiles:
|
|
268
|
-
removeFiles:
|
|
269
|
-
addFiles:
|
|
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 &&
|
|
272
|
-
const
|
|
273
|
-
|
|
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:
|
|
268
|
+
cancelFiles: D
|
|
276
269
|
};
|
|
277
270
|
}
|
|
278
271
|
export {
|
|
@@ -1,123 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import i from "axios";
|
|
2
|
+
function o(a) {
|
|
3
3
|
return {
|
|
4
|
-
login: async (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
68
|
+
o as simpleAuthProvider
|
|
123
69
|
};
|