1919
2020** Options 参数说明:**
2121
22- | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
23- | ------------- | -------------------------------- | -------- | ------ | -------------------------------------------------------------------------------- |
24- | ` filename ` | string | 否 | | 保存的文件名,** 添加此参数时会将压缩包保存到本地,未配置返回压缩包的 Blob 对象** |
25- | ` resources ` | Resource[ ] | 是 | | 资源列表,数组,每个元素为对象,包含 ` name ` 和 ` url ` 或者 ` blob ` 字段 |
26- | ` concurrency ` | number | 否 | ` 10 ` | 并发数,默认 ` 10 ` |
27- | ` onProgress ` | (index: number) => Promise<void > | 否 | | 下载进度回调函数,参数为当前正在下载的资源索引 |
22+ | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
23+ | ------------- | ----------------------------------------- | -------- | ------ | -------------------------------------------------------------------------------- |
24+ | ` filename ` | string | 否 | | 保存的文件名,** 添加此参数时会将压缩包保存到本地,未配置返回压缩包的 Blob 对象** |
25+ | ` resources ` | ( Resource \| () => Promise \< Resource \> ) [ ] | 是 | | 资源列表,数组,每个元素为对象,包含 ` name ` 和 ` url ` 或者 ` blob ` 字段 |
26+ | ` concurrency ` | number | 否 | ` 10 ` | 并发数,默认 ` 10 ` |
27+ | ` onProgress ` | (index: number) => Promise\ < void\> | 否 | | 下载进度回调函数,参数为当前正在下载的资源索引 |
2828
2929** Resource 参数说明:**
3030
31- | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
32- | ------ | ----------------------------- | -------- | ------ | ------------- |
33- | ` name ` | string | 是 | | 资源名称 |
34- | ` url ` | string | 否 | | URL 类型资源 |
35- | ` blob ` | Blob 或者 () => Promise<Blob > | 否 | | Blob 类型资源 |
31+ | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
32+ | ------ | ------------------------------- | -------- | ------ | ------------- |
33+ | ` name ` | string | 是 | | 资源名称 |
34+ | ` url ` | string | 否 | | URL 类型资源 |
35+ | ` blob ` | Blob 或者 () => Promise\ < Blob\ > | 否 | | Blob 类型资源 |
3636
3737## 📦 使用示例
3838
@@ -48,12 +48,13 @@ await zipDownloader({
4848 blob: new Blob ([' hello world' ], { type: ' text/plain' }),
4949 },
5050 {
51- name: ' world.txt' ,
52- blob : async () => {
53- const response = await fetch (' https://example.com/world.txt' )
54- return response .blob ()
55- },
51+ name: ' example.txt' ,
52+ blob : () => fetch (' https://example.com' ).then (response => response .blob ()),
5653 },
54+ () => fetch (' https://example.com' ).then (response => ({
55+ name: ' example2.txt' ,
56+ blob : () => response .blob (),
57+ })),
5758 ],
5859 concurrency: 10 ,
5960 async onProgress(index ) {
@@ -73,12 +74,13 @@ const blob = await zipDownloader({
7374 blob: new Blob ([' hello world' ], { type: ' text/plain' }),
7475 },
7576 {
76- name: ' world.txt' ,
77- blob : async () => {
78- const response = await fetch (' https://example.com/world.txt' )
79- return response .blob ()
80- },
77+ name: ' example.txt' ,
78+ blob : () => fetch (' https://example.com' ).then (response => response .blob ()),
8179 },
80+ () => fetch (' https://example.com' ).then (response => ({
81+ name: ' example2.txt' ,
82+ blob : () => response .blob (),
83+ })),
8284 ],
8385 concurrency: 10 ,
8486 async onProgress(index ) {
0 commit comments