@base-web-kits/base-tools-web 1.2.6 → 1.2.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.
- package/dist/base-tools-web.umd.global.js +35 -48
- package/dist/base-tools-web.umd.global.js.map +1 -1
- package/dist/index.cjs +7 -955
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +640 -0
- package/dist/index.js +7 -969
- package/dist/index.js.map +1 -1
- package/dist/network/download.d.ts +0 -14
- package/dist/network/download.d.ts.map +1 -1
- package/dist/network/request.d.ts.map +1 -1
- package/package.json +1 -12
- package/src/web/async/index.ts +1 -1
- package/src/web/network/download.ts +0 -27
- package/src/web/network/request.ts +4 -7
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AxiosResponse } from 'axios';
|
|
2
1
|
/**
|
|
3
2
|
* 下载文件
|
|
4
3
|
* @param url 完整的下载地址 | base64字符串 | Blob对象
|
|
@@ -9,19 +8,6 @@ import type { AxiosResponse } from 'axios';
|
|
|
9
8
|
* download(blob, '图片.jpg');
|
|
10
9
|
*/
|
|
11
10
|
export declare function download(url: string | Blob, fileName?: string): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* 解析Axios返回的Blob数据
|
|
14
|
-
* @param res Axios响应对象 (responseType='blob')
|
|
15
|
-
* @returns 包含blob数据和文件名的对象 { blob, fileName }
|
|
16
|
-
* @example
|
|
17
|
-
* const res = await axios.get(url, { responseType: 'blob' });
|
|
18
|
-
* const { blob, fileName } = await parseAxiosBlob(res);
|
|
19
|
-
* download(blob, fileName);
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseAxiosBlob(res: AxiosResponse<Blob>): Promise<{
|
|
22
|
-
blob: Blob;
|
|
23
|
-
fileName: string;
|
|
24
|
-
}>;
|
|
25
11
|
/**
|
|
26
12
|
* 获取文件名
|
|
27
13
|
* @param disposition content-disposition头值
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/web/network/download.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/web/network/download.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,SAAK,iBAyC/D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,UAkB1D;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAC1B,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC,iBAuBnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,WAOhC;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,iBAuBvD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,WAOlC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,6BAOvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/web/network/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/web/network/request.ts"],"names":[],"mappings":"AAOA,aAAa;AACb,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,MAAM,GACN,KAAK,GACL,QAAQ,GACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,eAAe,GACf,IAAI,GACJ,QAAQ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,CAAC,QAAQ,CAAC,0BAQtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base-web-kits/base-tools-web",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Independent Web utilities package built from src/web.",
|
|
6
6
|
"keywords": [
|
|
@@ -24,17 +24,6 @@
|
|
|
24
24
|
"README.md",
|
|
25
25
|
"src"
|
|
26
26
|
],
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@base-web-kits/base-tools-ts": "^1.2.0"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"axios": ">=0.18.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"axios": {
|
|
35
|
-
"optional": true
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
27
|
"publishConfig": {
|
|
39
28
|
"registry": "https://registry.npmjs.org"
|
|
40
29
|
}
|
package/src/web/async/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AxiosResponse } from 'axios';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* 下载文件
|
|
5
3
|
* @param url 完整的下载地址 | base64字符串 | Blob对象
|
|
@@ -52,31 +50,6 @@ export async function download(url: string | Blob, fileName = '') {
|
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
/**
|
|
56
|
-
* 解析Axios返回的Blob数据
|
|
57
|
-
* @param res Axios响应对象 (responseType='blob')
|
|
58
|
-
* @returns 包含blob数据和文件名的对象 { blob, fileName }
|
|
59
|
-
* @example
|
|
60
|
-
* const res = await axios.get(url, { responseType: 'blob' });
|
|
61
|
-
* const { blob, fileName } = await parseAxiosBlob(res);
|
|
62
|
-
* download(blob, fileName);
|
|
63
|
-
*/
|
|
64
|
-
export async function parseAxiosBlob(res: AxiosResponse<Blob>) {
|
|
65
|
-
const { data, headers, status, statusText, config } = res;
|
|
66
|
-
|
|
67
|
-
if (status < 200 || status >= 300) throw new Error(`${status},${statusText}:${config.url}`);
|
|
68
|
-
|
|
69
|
-
// 抛出json错误
|
|
70
|
-
if (data.type.includes('application/json')) {
|
|
71
|
-
const txt = await data.text();
|
|
72
|
-
throw JSON.parse(txt);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 解析文件名
|
|
76
|
-
const fileName = getDispositionFileName(headers['content-disposition']);
|
|
77
|
-
return { blob: data, fileName };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
53
|
/**
|
|
81
54
|
* 获取文件名
|
|
82
55
|
* @param disposition content-disposition头值
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
isPlainObject,
|
|
6
|
-
toDayjs,
|
|
7
|
-
} from '@base-web-kits/base-tools-ts';
|
|
1
|
+
import { cloneDeep, isPlainObject } from 'es-toolkit';
|
|
2
|
+
import { toDayjs } from '../../ts/day';
|
|
3
|
+
import { getObjectValue } from '../../ts/object';
|
|
4
|
+
import { appendUrlParam } from '../../ts/url';
|
|
8
5
|
import { getBaseToolsConfig } from '../config';
|
|
9
6
|
import type { AppLogInfo } from '../config';
|
|
10
7
|
|