ztxkutils 2.9.13 → 2.9.14

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/request.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './tslib.es6-f9459658.js';
2
2
  import 'axios';
3
3
  import 'ztxkui';
4
- export { a as default } from './request-aaf0f9e0.js';
5
- import './authority-845a141d.js';
4
+ export { a as default } from './request-c3ba0965.js';
5
+ import './authority-118dc4b1.js';
6
6
  import './crypto-c481f616.js';
7
7
  import 'crypto';
@@ -1,6 +1,6 @@
1
1
  import Stomp from 'zt-stompjs';
2
2
  import SockJS from 'zt-sockjs-client';
3
- import { g as getToken } from './authority-845a141d.js';
3
+ import { g as getToken } from './authority-118dc4b1.js';
4
4
 
5
5
  var StompClient = /** @class */ (function () {
6
6
  function StompClient(connectWsConfig) {
@@ -1,36 +1,30 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { g as getToken } from './authority-845a141d.js';
2
+ import { createDownloadUrl } from './fileOperation.js';
3
+ import './authority-118dc4b1.js';
4
+ import './tools-1e6fe951.js';
5
+ import './tslib.es6-f9459658.js';
6
+ import 'dayjs';
7
+ import 'number-precision';
3
8
 
4
9
  /**
5
10
  * 图片附件id转base64字符串
6
11
  */
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
12
  function useFileIdToBase64(imgFileId, apiUrl, authToken) {
16
13
  var _a = useState(''), base64Img = _a[0], setBase64Img = _a[1];
17
14
  useEffect(function () {
18
15
  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
- }
16
+ var image_1 = new Image();
17
+ image_1.setAttribute('crossOrigin', 'anonymous');
18
+ image_1.src = createDownloadUrl(apiUrl, imgFileId);
19
+ image_1.onload = function () {
20
+ var canvas = document.createElement('canvas');
21
+ canvas.width = image_1.width;
22
+ canvas.height = image_1.height;
23
+ var ctx = canvas.getContext('2d');
24
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
25
+ var dataURL = canvas.toDataURL('image/png');
26
+ setBase64Img(dataURL);
32
27
  };
33
- xhr_1.send();
34
28
  }
35
29
  }, [imgFileId]);
36
30
  return {
@@ -1,6 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { useHistory as useHistory$1 } from 'react-router-dom';
3
- import { i as isQiankun } from './authority-845a141d.js';
3
+ import { i as isQiankun } from './authority-118dc4b1.js';
4
4
  import { WORKFLOW_HIDEFRAME_KEY } from './constants.js';
5
5
 
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.9.13",
3
+ "version": "2.9.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",