@base-web-kits/base-tools-web 1.1.18-alpha.0 → 1.1.18-alpha.1
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/async/index.d.ts +6 -6
- package/dist/async/index.d.ts.map +1 -1
- package/dist/base-tools-web.umd.global.js +4 -7
- package/dist/base-tools-web.umd.global.js.map +1 -1
- package/dist/index.cjs +4 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/network/uploadFile.d.ts +1 -1
- package/dist/network/uploadFile.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web/async/index.ts +10 -7
- package/src/web/network/uploadFile.ts +4 -10
package/dist/async/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
type WebApi<Option, Res, Config =
|
|
1
|
+
type WebApi<Option = any, Res = any, Config = any> = (option: Option, config?: Config) => Promise<Res>;
|
|
2
2
|
/**
|
|
3
3
|
* web api 的调用配置
|
|
4
4
|
*/
|
|
5
|
-
export type WebApiConfig<Res, Err> = {
|
|
5
|
+
export type WebApiConfig<Res = any, Err = any> = {
|
|
6
6
|
/** 是否显示加载提示, 默认 false. (支持字符串,自定义文本) */
|
|
7
7
|
showLoading?: boolean | string;
|
|
8
8
|
/** 操作成功的toast提示, 默认不显示 */
|
|
@@ -13,14 +13,14 @@ export type WebApiConfig<Res, Err> = {
|
|
|
13
13
|
showLog?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* 拓展 web api, 使其支持loading,toast,log
|
|
16
|
+
* 拓展 web api, 使其支持loading,toast,log能力
|
|
17
17
|
* @param webApi web api
|
|
18
|
-
* @param apiName web api 名称 (可选, 用于日志输出, 默认'
|
|
18
|
+
* @param apiName web api 名称 (可选, 用于日志输出, 默认'enhanceWebApi')
|
|
19
19
|
* @return 注入拓展能力的promise (默认提示异常和输出日志,不显示进度条和操作成功)
|
|
20
20
|
* @example
|
|
21
|
-
* const promise =
|
|
21
|
+
* const promise = enhanceWebApi(downloadFile, 'downloadFile');
|
|
22
22
|
* await promise({ url: 'xx' }, {showLoading: '下载中', toastSuccess: '下载成功'});
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function enhanceWebApi<Option = any, Res = any, Err = any, Config = any>(webApi: WebApi<Option, Res, Config>, apiName?: string): (option: Option, config?: WebApiConfig<Res, Err> & Config) => Promise<Res>;
|
|
25
25
|
export {};
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/async/index.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/async/index.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,CACnD,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC,GAAG,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI;IAC/C,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE/B,0BAA0B;IAC1B,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,GAAG,MAAM,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;IAE/D,wGAAwG;IACxG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,GAAG,MAAM,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC;IAE/D,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,EAC5E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EACnC,OAAO,CAAC,EAAE,MAAM,IAER,QAAQ,MAAM,EAAE,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,kBA+CjE"}
|
|
@@ -2057,7 +2057,7 @@ var baseToolsWeb = (() => {
|
|
|
2057
2057
|
}
|
|
2058
2058
|
|
|
2059
2059
|
// src/web/async/index.ts
|
|
2060
|
-
function
|
|
2060
|
+
function enhanceWebApi(webApi, apiName) {
|
|
2061
2061
|
return (option, config) => {
|
|
2062
2062
|
const finalConfig = config || {};
|
|
2063
2063
|
const {
|
|
@@ -2072,7 +2072,7 @@ var baseToolsWeb = (() => {
|
|
|
2072
2072
|
showLoading: showLoadingFn,
|
|
2073
2073
|
hideLoading: hideLoadingFn
|
|
2074
2074
|
} = getBaseToolsConfig();
|
|
2075
|
-
const fname = apiName || "
|
|
2075
|
+
const fname = apiName || "enhanceWebApi";
|
|
2076
2076
|
if (showLoading) {
|
|
2077
2077
|
const title = typeof showLoading === "string" ? showLoading : "";
|
|
2078
2078
|
showLoadingFn == null ? void 0 : showLoadingFn({ title });
|
|
@@ -2152,17 +2152,14 @@ var baseToolsWeb = (() => {
|
|
|
2152
2152
|
data.append(name, file);
|
|
2153
2153
|
if (formData) {
|
|
2154
2154
|
Object.entries(formData).forEach(([k, v]) => {
|
|
2155
|
-
if (v !== void 0) data.append(k, String(v));
|
|
2155
|
+
if (v !== void 0 && v !== null) data.append(k, String(v));
|
|
2156
2156
|
});
|
|
2157
2157
|
}
|
|
2158
2158
|
xhr.send(data);
|
|
2159
2159
|
});
|
|
2160
2160
|
}
|
|
2161
2161
|
function uploadFile(option, config) {
|
|
2162
|
-
return
|
|
2163
|
-
option,
|
|
2164
|
-
config
|
|
2165
|
-
);
|
|
2162
|
+
return enhanceWebApi(upload, "uploadFile")(option, config);
|
|
2166
2163
|
}
|
|
2167
2164
|
|
|
2168
2165
|
// src/web/storage/index.ts
|