@base-web-kits/base-tools-web 1.1.18-alpha.1 → 1.2.0-alpha.0
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 +4 -0
- package/dist/async/index.d.ts.map +1 -1
- package/dist/base-tools-web.umd.global.js +19 -7
- package/dist/base-tools-web.umd.global.js.map +1 -1
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/network/request.d.ts +2 -2
- package/dist/network/request.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web/async/index.ts +30 -4
- package/src/web/network/request.ts +8 -4
- package/src/web/storage/index.ts +1 -3
package/dist/index.cjs
CHANGED
|
@@ -1801,7 +1801,7 @@ function logRequestInfo(options) {
|
|
|
1801
1801
|
const { isLog = true } = options.config;
|
|
1802
1802
|
if (!log || !isLog) return;
|
|
1803
1803
|
const { config, res, fromCache = false, startTime, status, e } = options;
|
|
1804
|
-
const { url, data, header, method,
|
|
1804
|
+
const { url, data, header, method, logExtra } = config;
|
|
1805
1805
|
const endTime = Date.now();
|
|
1806
1806
|
const fmt = "YYYY-MM-DD HH:mm:ss.SSS";
|
|
1807
1807
|
const info = __spreadValues({
|
|
@@ -1815,7 +1815,7 @@ function logRequestInfo(options) {
|
|
|
1815
1815
|
startTime: toDayjs(startTime).format(fmt),
|
|
1816
1816
|
endTime: toDayjs(endTime).format(fmt),
|
|
1817
1817
|
duration: endTime - startTime
|
|
1818
|
-
},
|
|
1818
|
+
}, logExtra);
|
|
1819
1819
|
if (status === "success") {
|
|
1820
1820
|
info.res = (0, ts_exports.cloneDeep)(res);
|
|
1821
1821
|
log("info", info);
|
|
@@ -1912,7 +1912,9 @@ function enhanceWebApi(webApi, apiName) {
|
|
|
1912
1912
|
showLoading = false,
|
|
1913
1913
|
toastSuccess = false,
|
|
1914
1914
|
toastError = true,
|
|
1915
|
-
showLog = true
|
|
1915
|
+
showLog = true,
|
|
1916
|
+
resFilter,
|
|
1917
|
+
logExtra
|
|
1916
1918
|
} = finalConfig;
|
|
1917
1919
|
const {
|
|
1918
1920
|
log,
|
|
@@ -1928,13 +1930,23 @@ function enhanceWebApi(webApi, apiName) {
|
|
|
1928
1930
|
return new Promise((resolve, reject) => {
|
|
1929
1931
|
webApi(option, finalConfig).then((res) => {
|
|
1930
1932
|
if (showLoading) hideLoadingFn == null ? void 0 : hideLoadingFn();
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1933
|
+
const finalRes = resFilter ? resFilter(res) : res;
|
|
1934
|
+
if (showLog) {
|
|
1935
|
+
const logData = __spreadValues({ name: fname, status: "success", option }, logExtra);
|
|
1936
|
+
if (resFilter) {
|
|
1937
|
+
logData.res = res;
|
|
1938
|
+
logData.resFilter = (0, ts_exports.cloneDeep)(finalRes);
|
|
1939
|
+
} else {
|
|
1940
|
+
logData.res = (0, ts_exports.cloneDeep)(res);
|
|
1941
|
+
}
|
|
1942
|
+
log == null ? void 0 : log("info", logData);
|
|
1943
|
+
}
|
|
1944
|
+
resolve(finalRes);
|
|
1945
|
+
const msg = typeof toastSuccess === "function" ? toastSuccess(finalRes) : toastSuccess;
|
|
1934
1946
|
if (msg) toast == null ? void 0 : toast({ msg, status: "success" });
|
|
1935
1947
|
}).catch((e) => {
|
|
1936
1948
|
if (showLoading) hideLoadingFn == null ? void 0 : hideLoadingFn();
|
|
1937
|
-
if (showLog) log == null ? void 0 : log("error", { name: fname, status: "fail", option, e });
|
|
1949
|
+
if (showLog) log == null ? void 0 : log("error", __spreadValues({ name: fname, status: "fail", option, e }, logExtra));
|
|
1938
1950
|
const msg = typeof toastError === "function" ? toastError(e) : toastError;
|
|
1939
1951
|
if (msg) {
|
|
1940
1952
|
toast == null ? void 0 : toast({
|