@das-fed/utils 6.4.0-hot.23 → 6.4.0-hot.25
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/api-services/index.js +891 -890
- package/api-services/index.js.gz +0 -0
- package/api-services/modules/file/index.d.ts +1 -0
- package/api-services/modules/file/index.js +75 -74
- package/api-services/modules/file/index.js.gz +0 -0
- package/api-services/modules/index.js +891 -890
- package/api-services/modules/index.js.gz +0 -0
- package/create-api-service/sso/index.js +9 -9
- package/create-api-service/sso/index.js.gz +0 -0
- package/package.json +4 -4
package/api-services/index.js.gz
CHANGED
|
Binary file
|
|
@@ -26,6 +26,7 @@ export declare const useFile: () => {
|
|
|
26
26
|
downloadFile: (path: any, filename: string, fileSuffix?: string) => void;
|
|
27
27
|
resetStataus: () => void;
|
|
28
28
|
checkProgress: (taskId: any, type: string, fileName: string, fileSuffix?: string) => any;
|
|
29
|
+
fileHandleType: any;
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
32
|
* 下载文件
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { iotMinio as
|
|
2
|
-
import { extractFilename as
|
|
3
|
-
import { ref as
|
|
4
|
-
import
|
|
1
|
+
import { iotMinio as A, iotProgress as Z } from "@das-fed/utils/api-services/modules/iot";
|
|
2
|
+
import { extractFilename as F } from "@das-fed/utils/common-tools";
|
|
3
|
+
import { ref as m } from "vue";
|
|
4
|
+
import ee from "dayjs";
|
|
5
5
|
import { t as i } from "@das-fed/web/packages/i18n/index";
|
|
6
6
|
import { getConfig as B } from "@das-fed/utils/config";
|
|
7
|
-
let
|
|
7
|
+
let te = (e = 21) => {
|
|
8
8
|
let o = "", u = crypto.getRandomValues(new Uint8Array(e));
|
|
9
9
|
for (; e--; ) {
|
|
10
10
|
let s = u[e] & 63;
|
|
@@ -12,78 +12,78 @@ let ee = (e = 21) => {
|
|
|
12
12
|
}
|
|
13
13
|
return o;
|
|
14
14
|
};
|
|
15
|
-
const
|
|
16
|
-
let e =
|
|
17
|
-
const
|
|
15
|
+
const se = A.get("token"), ae = A.post("put-object", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), re = A.post("upload-objects", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), oe = Z.get("progress"), de = () => {
|
|
16
|
+
let e = m(!1), o = m(""), u = m(0), s = m("normal"), g = m(!1), f, h = m(""), w = m(""), T = m(""), b = m(""), $ = m(!1), L = m(""), P = "", U = m(""), I;
|
|
17
|
+
const Y = () => {
|
|
18
18
|
w.value = "", T.value = "", b.value = "", $.value = !1, L.value = "";
|
|
19
|
-
},
|
|
20
|
-
const [a, r] = await
|
|
19
|
+
}, J = async () => {
|
|
20
|
+
const [a, r] = await se().run();
|
|
21
21
|
return a ? { stauts: !1 } : { status: !0, data: r };
|
|
22
|
-
},
|
|
22
|
+
}, K = (a) => new Promise((r, l) => {
|
|
23
23
|
const c = [];
|
|
24
24
|
let t = 0;
|
|
25
25
|
for (; t < a.size; ) {
|
|
26
|
-
const
|
|
27
|
-
c.push(
|
|
26
|
+
const v = a.slice(t, t + 1048576);
|
|
27
|
+
c.push(v), t += 1048576;
|
|
28
28
|
}
|
|
29
29
|
const d = new Blob(c, { type: a.type });
|
|
30
30
|
r(d);
|
|
31
|
-
}),
|
|
32
|
-
var
|
|
33
|
-
P = c, n && (s.value = "normal", u.value = 0, o.value = i("导入进度"), e.value = !0, h.value = ""),
|
|
34
|
-
const d = await
|
|
31
|
+
}), V = async (a, r, l, n = !0, c = "", t = !1) => {
|
|
32
|
+
var H, O;
|
|
33
|
+
P = c, U.value = "import", n && (s.value = "normal", u.value = 0, o.value = i("导入进度"), e.value = !0, h.value = ""), I = r;
|
|
34
|
+
const d = await J();
|
|
35
35
|
if (!d.status) return;
|
|
36
|
-
let
|
|
37
|
-
const
|
|
36
|
+
let v = d.data, p = null, { autoContentType: y, bucketName: j, importFileName: E } = l;
|
|
37
|
+
const G = t ? re : ae;
|
|
38
38
|
if (t) {
|
|
39
39
|
let M = [];
|
|
40
40
|
await r.forEach(async (R) => {
|
|
41
|
-
let
|
|
42
|
-
M.push(
|
|
43
|
-
}), p = new FormData(), p.append("accessKeyId",
|
|
44
|
-
p.append("file", M[
|
|
45
|
-
}),
|
|
41
|
+
let N = await K(R);
|
|
42
|
+
M.push(N);
|
|
43
|
+
}), p = new FormData(), p.append("accessKeyId", v.accessKeyId), p.append("secretAccessKey", v.secretAccessKey), p.append("sessionToken", v.sessionToken), p.append("bucketName", j), r.forEach((R, N) => {
|
|
44
|
+
p.append("file", M[N]);
|
|
45
|
+
}), E.forEach((R) => {
|
|
46
46
|
p.append("filePaths", R);
|
|
47
47
|
});
|
|
48
48
|
} else {
|
|
49
|
-
const M = await
|
|
49
|
+
const M = await K(r);
|
|
50
50
|
p = {
|
|
51
|
-
accessKeyId:
|
|
52
|
-
secretAccessKey:
|
|
53
|
-
sessionToken:
|
|
51
|
+
accessKeyId: v.accessKeyId,
|
|
52
|
+
secretAccessKey: v.secretAccessKey,
|
|
53
|
+
sessionToken: v.sessionToken,
|
|
54
54
|
file: M,
|
|
55
55
|
bucketName: j,
|
|
56
|
-
filePath:
|
|
56
|
+
filePath: E,
|
|
57
57
|
autoContentType: y
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
const [
|
|
61
|
-
if (
|
|
62
|
-
const x = await
|
|
60
|
+
const [Q, W] = await G(p).run();
|
|
61
|
+
if (Q) return e.value = !1;
|
|
62
|
+
const x = await ne(W.data);
|
|
63
63
|
if ((x == null ? void 0 : x.statusCode) != 200) {
|
|
64
|
-
e.value = !1, (
|
|
64
|
+
e.value = !1, (H = window.DasMessage) == null || H.error({
|
|
65
65
|
message: (x == null ? void 0 : x.errorMsg) || i("上传失败"),
|
|
66
66
|
grouping: !0,
|
|
67
67
|
repeatNum: 1
|
|
68
68
|
});
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const C = await (a == null ? void 0 : a(x));
|
|
72
72
|
if (n) {
|
|
73
|
-
if (!
|
|
73
|
+
if (!C.status) {
|
|
74
74
|
e.value = !1, s.value = "error";
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
o.value = i("导入进度"), e.value = !0, k(
|
|
77
|
+
o.value = i("导入进度"), e.value = !0, k(C.taskId, "import", "");
|
|
78
78
|
} else {
|
|
79
|
-
if (!
|
|
79
|
+
if (!C.status) return;
|
|
80
80
|
s.value = "success", (O = window.DasMessage) == null || O.success({
|
|
81
81
|
message: i("导入成功"),
|
|
82
82
|
grouping: !0,
|
|
83
83
|
repeatNum: 1
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
},
|
|
86
|
+
}, X = async (a, r = "", l = "") => {
|
|
87
87
|
s.value = "normal", u.value = 0, o.value = l || i("导出进度"), e.value = !0;
|
|
88
88
|
const n = await (a == null ? void 0 : a());
|
|
89
89
|
if (!n.status) {
|
|
@@ -91,22 +91,22 @@ const te = N.get("token"), se = N.post("put-object", (e) => (e.headers || (e.hea
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
k(n.taskId, "action", "");
|
|
94
|
-
},
|
|
95
|
-
n && (s.value = "normal", u.value = 0, o.value = i("导出进度"), e.value = !0);
|
|
94
|
+
}, _ = async (a, r = "", l = "", n = !0) => {
|
|
95
|
+
U.value = "export", n && (s.value = "normal", u.value = 0, o.value = i("导出进度"), e.value = !0);
|
|
96
96
|
const c = await (a == null ? void 0 : a());
|
|
97
97
|
if (!c.status) {
|
|
98
98
|
e.value = !1, s.value = "error";
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
ee().format("YYYYMMDDHHmmss") + "", k(c.taskId, "export", r || "", l);
|
|
102
102
|
}, k = async (a, r, l, n = "") => {
|
|
103
|
-
g.value = !0,
|
|
103
|
+
g.value = !0, D(a, r, l, n), f = setTimeout(() => {
|
|
104
104
|
}, 50);
|
|
105
|
-
},
|
|
106
|
-
clearTimeout(
|
|
107
|
-
},
|
|
108
|
-
var
|
|
109
|
-
const [c, t] = await
|
|
105
|
+
}, S = () => {
|
|
106
|
+
clearTimeout(f), f = null, e.value = !1;
|
|
107
|
+
}, D = async (a, r = "export", l, n = "") => {
|
|
108
|
+
var v, p;
|
|
109
|
+
const [c, t] = await oe("", {
|
|
110
110
|
url: `progress/${a}`
|
|
111
111
|
}).run();
|
|
112
112
|
if (c) {
|
|
@@ -116,8 +116,8 @@ const te = N.get("token"), se = N.post("put-object", (e) => (e.headers || (e.hea
|
|
|
116
116
|
u.value = t.percentage;
|
|
117
117
|
const d = r == "export" ? i("导出") : i("导入");
|
|
118
118
|
if (u.value == 100)
|
|
119
|
-
if (h.value = t, g.value = !1,
|
|
120
|
-
t.status == 1 ? (s.value = "success",
|
|
119
|
+
if (h.value = t, g.value = !1, S(), r == "export")
|
|
120
|
+
t.status == 1 ? (s.value = "success", q(`${B().baseURL}/oss${t.filePath}`, l, n), g.value = !1) : t.status == 2 && (b.value = t.message || `${d}${i("失败")}`, (v = window.DasMessage) == null || v.error({
|
|
121
121
|
message: t.message || `${d}${i("失败")}`,
|
|
122
122
|
grouping: !0,
|
|
123
123
|
repeatNum: 1
|
|
@@ -125,17 +125,17 @@ const te = N.get("token"), se = N.post("put-object", (e) => (e.headers || (e.hea
|
|
|
125
125
|
else if (r == "import") {
|
|
126
126
|
if (t.filePath) {
|
|
127
127
|
s.value = "error", $.value = !0;
|
|
128
|
-
let y = await
|
|
128
|
+
let y = await F(`/oss/${t == null ? void 0 : t.filePath}`);
|
|
129
129
|
const j = ((p = y == null ? void 0 : y.split("/")) == null ? void 0 : p.pop()) || "";
|
|
130
|
-
w.value = P || j, T.value =
|
|
130
|
+
w.value = P || j, T.value = I.sizeText, b.value = i("部分数据校验不通过,请下载附件并修改,重新导入!"), L.value = `${B().baseURL}/oss/${t == null ? void 0 : t.filePath}`;
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
z(t.status, d, t.message);
|
|
133
133
|
} else r == "action" && (s.value = "success");
|
|
134
134
|
else
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}, 50) : (h.value = t, g.value = !1,
|
|
138
|
-
},
|
|
135
|
+
f && t.status != 2 ? f = setTimeout(() => {
|
|
136
|
+
D(a, r, l, n);
|
|
137
|
+
}, 50) : (h.value = t, g.value = !1, z(t.status, d, t.message), S(), $.value = !0, b.value = (t == null ? void 0 : t.message) || "");
|
|
138
|
+
}, z = (a, r, l) => {
|
|
139
139
|
var n, c, t;
|
|
140
140
|
a == 1 ? (s.value = "success", (n = window.DasMessage) == null || n.success({
|
|
141
141
|
message: `${r}${i("成功")}`,
|
|
@@ -163,18 +163,19 @@ const te = N.get("token"), se = N.post("put-object", (e) => (e.headers || (e.hea
|
|
|
163
163
|
errorMessage: b,
|
|
164
164
|
errorImport: $,
|
|
165
165
|
errorFilePath: L,
|
|
166
|
-
fileImport:
|
|
167
|
-
fileExport:
|
|
168
|
-
fileAction:
|
|
166
|
+
fileImport: V,
|
|
167
|
+
fileExport: _,
|
|
168
|
+
fileAction: X,
|
|
169
169
|
generateUniqueName: (a) => {
|
|
170
170
|
const r = a == null ? void 0 : a.match(/(.*?)(\.[^.]*$|$)/), l = r.length ? r[2] : "";
|
|
171
|
-
return `${r.length ? r[1] : a}${
|
|
171
|
+
return `${r.length ? r[1] : a}${te()}${l}`;
|
|
172
172
|
},
|
|
173
|
-
downloadFile:
|
|
174
|
-
resetStataus:
|
|
175
|
-
checkProgress: k
|
|
173
|
+
downloadFile: q,
|
|
174
|
+
resetStataus: Y,
|
|
175
|
+
checkProgress: k,
|
|
176
|
+
fileHandleType: U
|
|
176
177
|
};
|
|
177
|
-
},
|
|
178
|
+
}, le = (e) => {
|
|
178
179
|
let o = e == null ? void 0 : e.toLocaleLowerCase();
|
|
179
180
|
return {
|
|
180
181
|
excel: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
@@ -203,27 +204,27 @@ const te = N.get("token"), se = N.post("put-object", (e) => (e.headers || (e.hea
|
|
|
203
204
|
der: "application/x-x509-ca-cert",
|
|
204
205
|
cer: "application/pkix-cert"
|
|
205
206
|
}[o];
|
|
206
|
-
},
|
|
207
|
+
}, q = (e, o, u = "excel") => {
|
|
207
208
|
const s = new XMLHttpRequest();
|
|
208
209
|
s.open("get", e), s.setRequestHeader("Content-Type", "application/json; charset=UTF-8"), s.responseType = "blob", s.onload = function(g) {
|
|
209
|
-
const
|
|
210
|
-
type:
|
|
211
|
-
}), h = URL.createObjectURL(
|
|
210
|
+
const f = new Blob([this.response], {
|
|
211
|
+
type: le(u)
|
|
212
|
+
}), h = URL.createObjectURL(f);
|
|
212
213
|
if (window.navigator.msSaveOrOpenBlob)
|
|
213
|
-
navigator.msSaveBlob(
|
|
214
|
+
navigator.msSaveBlob(f, o);
|
|
214
215
|
else {
|
|
215
216
|
const w = document.createElement("a");
|
|
216
217
|
w.href = h, w.download = o, w.click(), window.URL.revokeObjectURL(h);
|
|
217
218
|
}
|
|
218
219
|
}, s.send();
|
|
219
|
-
},
|
|
220
|
+
}, ne = (e) => new Promise((o, u) => {
|
|
220
221
|
var s = new FileReader();
|
|
221
222
|
s.onload = function(g) {
|
|
222
|
-
let
|
|
223
|
-
typeof s.result == "string" && (
|
|
223
|
+
let f = "";
|
|
224
|
+
typeof s.result == "string" && (f = JSON.parse(s.result)), o(f);
|
|
224
225
|
}, s.readAsText(e);
|
|
225
226
|
});
|
|
226
227
|
export {
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
q as downloadFile,
|
|
229
|
+
de as useFile
|
|
229
230
|
};
|
|
Binary file
|