@tarojs/taro-h5 3.5.7-alpha.9 → 3.5.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.
@@ -24,6 +24,7 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
24
24
  image.style.maxWidth = '100%';
25
25
  image.src = url;
26
26
  const div = document.createElement('div');
27
+ div.classList.add('swiper-zoom-container');
27
28
  div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
28
29
  div.appendChild(image);
29
30
  item.appendChild(div);
@@ -54,6 +55,8 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
54
55
  const swiper = document.createElement('taro-swiper-core');
55
56
  // @ts-ignore
56
57
  swiper.full = true;
58
+ // @ts-ignore
59
+ swiper.zoom = true;
57
60
  let children = [];
58
61
  try {
59
62
  children = yield Promise.all(urls.map(e => loadImage(e, fail)));
@@ -1,7 +1,7 @@
1
1
  import { CallbackManager } from '../../utils/handler';
2
2
  import { NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils';
3
- const createDownloadTask = ({ url, header, withCredentials = true, success, error }) => {
4
- let timeout;
3
+ const createDownloadTask = ({ url, header, withCredentials = true, timeout, success, error }) => {
4
+ let timeoutInter;
5
5
  const apiName = 'downloadFile';
6
6
  const xhr = new XMLHttpRequest();
7
7
  const callbackManager = {
@@ -37,7 +37,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
37
37
  });
38
38
  };
39
39
  xhr.onabort = () => {
40
- clearTimeout(timeout);
40
+ clearTimeout(timeoutInter);
41
41
  error({
42
42
  errMsg: `${apiName}:fail abort`
43
43
  });
@@ -55,7 +55,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
55
55
  };
56
56
  const send = () => {
57
57
  xhr.send();
58
- timeout = setTimeout(() => {
58
+ timeoutInter = setTimeout(() => {
59
59
  xhr.onabort = null;
60
60
  xhr.onload = null;
61
61
  xhr.onprogress = null;
@@ -65,7 +65,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
65
65
  error({
66
66
  errMsg: `${apiName}:fail timeout`
67
67
  });
68
- }, NETWORK_TIMEOUT);
68
+ }, timeout || NETWORK_TIMEOUT);
69
69
  };
70
70
  send();
71
71
  /**
@@ -100,13 +100,14 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
100
100
  * 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
101
101
  * 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
102
102
  */
103
- export const downloadFile = ({ url, header, withCredentials, success, fail, complete }) => {
103
+ export const downloadFile = ({ url, header, withCredentials, timeout, success, fail, complete }) => {
104
104
  let task;
105
105
  const result = new Promise((resolve, reject) => {
106
106
  task = createDownloadTask({
107
107
  url,
108
108
  header,
109
109
  withCredentials,
110
+ timeout,
110
111
  success: res => {
111
112
  success && success(res);
112
113
  complete && complete(res);
package/dist/index.cjs.js CHANGED
@@ -2335,6 +2335,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2335
2335
  image.style.maxWidth = '100%';
2336
2336
  image.src = url;
2337
2337
  const div = document.createElement('div');
2338
+ div.classList.add('swiper-zoom-container');
2338
2339
  div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
2339
2340
  div.appendChild(image);
2340
2341
  item.appendChild(div);
@@ -2365,6 +2366,8 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2365
2366
  const swiper = document.createElement('taro-swiper-core');
2366
2367
  // @ts-ignore
2367
2368
  swiper.full = true;
2369
+ // @ts-ignore
2370
+ swiper.zoom = true;
2368
2371
  let children = [];
2369
2372
  try {
2370
2373
  children = yield Promise.all(urls.map(e => loadImage(e, fail)));
@@ -2660,8 +2663,8 @@ const convertObjectUrlToBlob = url => {
2660
2663
  });
2661
2664
  };
2662
2665
 
2663
- const createDownloadTask = ({ url, header, withCredentials = true, success, error }) => {
2664
- let timeout;
2666
+ const createDownloadTask = ({ url, header, withCredentials = true, timeout, success, error }) => {
2667
+ let timeoutInter;
2665
2668
  const apiName = 'downloadFile';
2666
2669
  const xhr = new XMLHttpRequest();
2667
2670
  const callbackManager = {
@@ -2697,7 +2700,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2697
2700
  });
2698
2701
  };
2699
2702
  xhr.onabort = () => {
2700
- clearTimeout(timeout);
2703
+ clearTimeout(timeoutInter);
2701
2704
  error({
2702
2705
  errMsg: `${apiName}:fail abort`
2703
2706
  });
@@ -2715,7 +2718,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2715
2718
  };
2716
2719
  const send = () => {
2717
2720
  xhr.send();
2718
- timeout = setTimeout(() => {
2721
+ timeoutInter = setTimeout(() => {
2719
2722
  xhr.onabort = null;
2720
2723
  xhr.onload = null;
2721
2724
  xhr.onprogress = null;
@@ -2725,7 +2728,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2725
2728
  error({
2726
2729
  errMsg: `${apiName}:fail timeout`
2727
2730
  });
2728
- }, NETWORK_TIMEOUT);
2731
+ }, timeout || NETWORK_TIMEOUT);
2729
2732
  };
2730
2733
  send();
2731
2734
  /**
@@ -2760,13 +2763,14 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2760
2763
  * 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
2761
2764
  * 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
2762
2765
  */
2763
- const downloadFile = ({ url, header, withCredentials, success, fail, complete }) => {
2766
+ const downloadFile = ({ url, header, withCredentials, timeout, success, fail, complete }) => {
2764
2767
  let task;
2765
2768
  const result = new Promise((resolve, reject) => {
2766
2769
  task = createDownloadTask({
2767
2770
  url,
2768
2771
  header,
2769
2772
  withCredentials,
2773
+ timeout,
2770
2774
  success: res => {
2771
2775
  success && success(res);
2772
2776
  complete && complete(res);