File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# @xiaohuohumax/xpath-selector
22
3+ ## 2.1.0
4+
5+ ### Minor Changes
6+
7+ - Blob 数据支持动态获取
8+
39## 2.0.3
410
511### Patch Changes
Original file line number Diff line number Diff line change 2828
2929** Resource 参数说明:**
3030
31- | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
32- | ------ | ------ | -------- | ------ | ------------- |
33- | ` name ` | string | 是 | | 资源名称 |
34- | ` url ` | string | 否 | | URL 类型资源 |
35- | ` blob ` | Blob | 否 | | Blob 类型资源 |
31+ | 参数名 | 类型 | 是否必填 | 默认值 | 说明 |
32+ | ------ | ----------------------------- | -------- | ------ | ------------- |
33+ | ` name ` | string | 是 | | 资源名称 |
34+ | ` url ` | string | 否 | | URL 类型资源 |
35+ | ` blob ` | Blob 或者 () => Promise< Blob > | 否 | | Blob 类型资源 |
3636
3737## 📦 使用示例
3838
@@ -47,6 +47,13 @@ await zipDownloader({
4747 name: ' hello.txt' ,
4848 blob: new Blob ([' hello world' ], { type: ' text/plain' }),
4949 },
50+ {
51+ name: ' world.txt' ,
52+ blob : async () => {
53+ const response = await fetch (' https://example.com/world.txt' )
54+ return response .blob ()
55+ },
56+ },
5057 ],
5158 concurrency: 10 ,
5259 async onProgress(index ) {
@@ -65,6 +72,13 @@ const blob = await zipDownloader({
6572 name: ' hello.txt' ,
6673 blob: new Blob ([' hello world' ], { type: ' text/plain' }),
6774 },
75+ {
76+ name: ' world.txt' ,
77+ blob : async () => {
78+ const response = await fetch (' https://example.com/world.txt' )
79+ return response .blob ()
80+ },
81+ },
6882 ],
6983 concurrency: 10 ,
7084 async onProgress(index ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " @xiaohuohumax/zip-downloader" ,
33 "type" : " module" ,
4- "version" : " 2.0.3 " ,
4+ "version" : " 2.1.0 " ,
55 "description" : " Zip Downloader -- 资源下载器(下载资源、Zip 压缩、下载到本地)" ,
66 "author" : {
77 "name" : " xiaohuohumax" ,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export interface UrlResource {
88
99export interface BlobResource {
1010 name : string
11- blob : Blob
11+ blob : Blob | ( ( ) => Promise < Blob > )
1212}
1313
1414function isBlobResource ( resource : Resource ) : resource is BlobResource {
@@ -43,7 +43,7 @@ export default async function zipDownloader(options: Options): Promise<void | Bl
4343 await Promise . all ( options . resources . map ( ( resource , index ) => limit ( async ( ) => {
4444 await options . onProgress ?.( index )
4545 const reader = isBlobResource ( resource )
46- ? new BlobReader ( resource . blob )
46+ ? new BlobReader ( typeof resource . blob === 'function' ? await resource . blob ( ) : resource . blob )
4747 : new HttpReader ( resource . url )
4848 return writer . add ( resource . name , reader )
4949 } ) ) )
You can’t perform that action at this time.
0 commit comments