@vtx/components 4.0.0-beta.59 → 4.0.0-beta.61

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.
@@ -10,13 +10,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ function _readOnlyError(name) { throw new TypeError("\"" + name + "\" is read-only"); }
13
14
  import React, { useRef, useEffect, useContext } from 'react';
14
15
  import { message, Button, Tooltip } from 'antd';
15
16
  import PropTypes from 'prop-types';
16
17
  import useSet from "../utils/useSet";
17
18
  import VtxImportResult from "./result";
18
19
  import getToken from "../utils/getToken";
19
- var token = getToken();
20
20
  import md5 from 'md5';
21
21
  import { getVtxToken, getSignature } from '@vtx/utils';
22
22
  import { useStyle } from "./style/index";
@@ -25,6 +25,10 @@ import VtxModal from "../vtx-modal";
25
25
  import { jsx as _jsx } from "react/jsx-runtime";
26
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
27
27
  function VtxImport(props) {
28
+ var token = getToken();
29
+ if (props.token) {
30
+ props.token, _readOnlyError("token");
31
+ }
28
32
  var intl = useIntl();
29
33
  var _useContext = useContext(VtxProvider),
30
34
  getPrefixCls = _useContext.getPrefixCls;
@@ -171,6 +175,8 @@ function VtxImport(props) {
171
175
  };
172
176
  // 发送请求
173
177
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
178
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
179
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
174
180
  var data = new FormData();
175
181
  data.append('chunkId', state.chunkId);
176
182
  data.append('tenantId', getVtxToken('tenantId'));
@@ -137,7 +137,7 @@ var VtxImport2 = function VtxImport2(props) {
137
137
  state = _useSet2[0],
138
138
  setState = _useSet2[1];
139
139
  var token = getToken();
140
- if (!token) {
140
+ if (props.token) {
141
141
  token = props.token;
142
142
  }
143
143
  var newErrorDownloadName = errorDownloadName;
@@ -207,6 +207,8 @@ var VtxImport2 = function VtxImport2(props) {
207
207
  xhr.onerror = function () {
208
208
  message.error(intl.getMessage('import.error', '上传失败'));
209
209
  };
210
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
211
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
210
212
  // 发送请求
211
213
  xhr.open('POST', '/cloudFile/common/uploadChunk', true);
212
214
  xhr.send(list[indexRef.current]);
@@ -234,6 +236,8 @@ var VtxImport2 = function VtxImport2(props) {
234
236
  };
235
237
  // 发送请求
236
238
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
239
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
240
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
237
241
  var data = new FormData();
238
242
  data.append('chunkId', state.chunkId);
239
243
  data.append('tenantId', getVtxToken('tenantId'));
@@ -32,8 +32,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
32
32
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
33
33
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
34
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
- var token = (0, _getToken.default)();
35
+ function _readOnlyError(name) { throw new TypeError("\"" + name + "\" is read-only"); }
36
36
  function VtxImport(props) {
37
+ var token = (0, _getToken.default)();
38
+ if (props.token) {
39
+ props.token, _readOnlyError("token");
40
+ }
37
41
  var intl = (0, _vtxProvider.useIntl)();
38
42
  var _useContext = (0, _react.useContext)(_vtxProvider.VtxProvider),
39
43
  getPrefixCls = _useContext.getPrefixCls;
@@ -180,6 +184,8 @@ function VtxImport(props) {
180
184
  };
181
185
  // 发送请求
182
186
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
187
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
188
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
183
189
  var data = new FormData();
184
190
  data.append('chunkId', state.chunkId);
185
191
  data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
@@ -143,7 +143,7 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
143
143
  state = _useSet2[0],
144
144
  setState = _useSet2[1];
145
145
  var token = (0, _getToken.default)();
146
- if (!token) {
146
+ if (props.token) {
147
147
  token = props.token;
148
148
  }
149
149
  var newErrorDownloadName = errorDownloadName;
@@ -213,6 +213,8 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
213
213
  xhr.onerror = function () {
214
214
  _antd.message.error(intl.getMessage('import.error', '上传失败'));
215
215
  };
216
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
217
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
216
218
  // 发送请求
217
219
  xhr.open('POST', '/cloudFile/common/uploadChunk', true);
218
220
  xhr.send(list[indexRef.current]);
@@ -240,6 +242,8 @@ var VtxImport2 = exports.VtxImport2 = function VtxImport2(props) {
240
242
  };
241
243
  // 发送请求
242
244
  xhr.open('POST', '/cloudFile/common/mergeChunk', true);
245
+ xhr.setRequestHeader('Authorization', token ? "Bearer ".concat(token) : '');
246
+ xhr.setRequestHeader('access_token', token ? "".concat(token) : '');
243
247
  var data = new FormData();
244
248
  data.append('chunkId', state.chunkId);
245
249
  data.append('tenantId', (0, _utils.getVtxToken)('tenantId'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtx/components",
3
- "version": "4.0.0-beta.59",
3
+ "version": "4.0.0-beta.61",
4
4
  "description": "React components for Vortex",
5
5
  "keywords": [
6
6
  "react",