ztxkutils 2.9.5 → 2.9.8
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/hooks/index.d.ts +2 -1
- package/dist/hooks/useFileIdToBase64.d.ts +3 -0
- package/dist/hooks.js +2 -0
- package/dist/useFileIdToBase64.js +41 -0
- package/dist/useHistory.js +17 -7
- package/package.json +1 -1
package/dist/hooks/index.d.ts
CHANGED
@@ -3,4 +3,5 @@ import useFetchState from './useFetchState';
|
|
3
3
|
import useTableValidate from './useTableValidate';
|
4
4
|
import useScreenFull from './useScreenFull';
|
5
5
|
import useMutationObserver from './useMutationObserver';
|
6
|
-
|
6
|
+
import useFileIdToBase64 from './useFileIdToBase64';
|
7
|
+
export { useTableLinkage, useFetchState, useTableValidate, useScreenFull, useMutationObserver, useFileIdToBase64, };
|
package/dist/hooks.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { _ as __assign, c as __awaiter, d as __generator } from './tslib.es6-f9459658.js';
|
2
2
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
3
|
+
export { default as useFileIdToBase64 } from './useFileIdToBase64.js';
|
4
|
+
import './authority-5bc06c1a.js';
|
3
5
|
|
4
6
|
function useTableLinkage(_a) {
|
5
7
|
var records = _a.records, callbackPromise = _a.callbackPromise, dependencies = _a.dependencies, devDependencies = _a.devDependencies;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { useState, useEffect } from 'react';
|
2
|
+
import { g as getToken } from './authority-5bc06c1a.js';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* 图片附件id转base64字符串
|
6
|
+
*/
|
7
|
+
function getBase64(blob) {
|
8
|
+
return new Promise(function (resolve, reject) {
|
9
|
+
var reader = new FileReader();
|
10
|
+
reader.readAsDataURL(blob);
|
11
|
+
reader.onload = function () { return resolve(reader.result); };
|
12
|
+
reader.onerror = function (error) { return reject(error); };
|
13
|
+
});
|
14
|
+
}
|
15
|
+
function useFileIdToBase64(imgFileId, apiUrl, authToken) {
|
16
|
+
var _a = useState(''), base64Img = _a[0], setBase64Img = _a[1];
|
17
|
+
useEffect(function () {
|
18
|
+
if (imgFileId) {
|
19
|
+
var xhr_1 = new XMLHttpRequest();
|
20
|
+
var token = getToken() || authToken;
|
21
|
+
var _apiUrl = apiUrl.endsWith('/')
|
22
|
+
? apiUrl.slice(0, apiUrl.length - 1)
|
23
|
+
: apiUrl;
|
24
|
+
xhr_1.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + imgFileId + "?Zmdms-Auth=bearer " + token, true);
|
25
|
+
xhr_1.responseType = 'blob';
|
26
|
+
xhr_1.onload = function () {
|
27
|
+
if (xhr_1.status === 200 || xhr_1.status === 201) {
|
28
|
+
getBase64(xhr_1.response).then(function (res) {
|
29
|
+
setBase64Img(res);
|
30
|
+
});
|
31
|
+
}
|
32
|
+
};
|
33
|
+
xhr_1.send();
|
34
|
+
}
|
35
|
+
}, [imgFileId]);
|
36
|
+
return {
|
37
|
+
base64Img: base64Img,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
export default useFileIdToBase64;
|
package/dist/useHistory.js
CHANGED
@@ -14,6 +14,8 @@ var _pushTarget = [
|
|
14
14
|
'_blank_noframe',
|
15
15
|
'_blank_close',
|
16
16
|
'_blank_nopre',
|
17
|
+
'_blank_frame',
|
18
|
+
'_blank_frame_nopre',
|
17
19
|
];
|
18
20
|
/**
|
19
21
|
* @author 陈亚雄
|
@@ -51,14 +53,20 @@ function useHistory(routeBasename) {
|
|
51
53
|
}
|
52
54
|
if (target === '_blank' ||
|
53
55
|
target === '_blank_noframe' ||
|
54
|
-
target === '_blank_nopre'
|
56
|
+
target === '_blank_nopre' ||
|
57
|
+
target === '_blank_frame' ||
|
58
|
+
target === '_blank_frame_nopre') {
|
55
59
|
// state 没法处理,请不要传递state,可以拼接再地址栏参数后面
|
56
60
|
// 新窗口打开的页面 都不需要菜单
|
57
|
-
var _path = path
|
58
|
-
|
59
|
-
|
60
|
-
?
|
61
|
-
|
61
|
+
var _path = path;
|
62
|
+
if (target !== '_blank_frame' && target !== '_blank_frame_nopre') {
|
63
|
+
_path =
|
64
|
+
path.indexOf('?') === -1
|
65
|
+
? path + "?" + WORKFLOW_HIDEFRAME_KEY + "=1"
|
66
|
+
: path.indexOf(WORKFLOW_HIDEFRAME_KEY) === -1
|
67
|
+
? path + "&" + WORKFLOW_HIDEFRAME_KEY + "=1"
|
68
|
+
: path;
|
69
|
+
}
|
62
70
|
// 是否是全路径
|
63
71
|
_path = _path.startsWith('http')
|
64
72
|
? _path
|
@@ -66,7 +74,9 @@ function useHistory(routeBasename) {
|
|
66
74
|
? _path
|
67
75
|
: "/" + _path;
|
68
76
|
// 如果在微前端里面,需要添加前缀
|
69
|
-
if (isQiankun() &&
|
77
|
+
if (isQiankun() &&
|
78
|
+
target !== '_blank_nopre' &&
|
79
|
+
target !== '_blank_frame_nopre') {
|
70
80
|
_path = _path.startsWith('http')
|
71
81
|
? _path
|
72
82
|
: routeBasename
|