@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.js
CHANGED
|
@@ -1732,7 +1732,7 @@ function logRequestInfo(options) {
|
|
|
1732
1732
|
const { isLog = true } = options.config;
|
|
1733
1733
|
if (!log || !isLog) return;
|
|
1734
1734
|
const { config, res, fromCache = false, startTime, status, e } = options;
|
|
1735
|
-
const { url, data, header, method,
|
|
1735
|
+
const { url, data, header, method, logExtra } = config;
|
|
1736
1736
|
const endTime = Date.now();
|
|
1737
1737
|
const fmt = "YYYY-MM-DD HH:mm:ss.SSS";
|
|
1738
1738
|
const info = __spreadValues({
|
|
@@ -1746,7 +1746,7 @@ function logRequestInfo(options) {
|
|
|
1746
1746
|
startTime: toDayjs(startTime).format(fmt),
|
|
1747
1747
|
endTime: toDayjs(endTime).format(fmt),
|
|
1748
1748
|
duration: endTime - startTime
|
|
1749
|
-
},
|
|
1749
|
+
}, logExtra);
|
|
1750
1750
|
if (status === "success") {
|
|
1751
1751
|
info.res = (0, ts_exports.cloneDeep)(res);
|
|
1752
1752
|
log("info", info);
|
|
@@ -1843,7 +1843,9 @@ function enhanceWebApi(webApi, apiName) {
|
|
|
1843
1843
|
showLoading = false,
|
|
1844
1844
|
toastSuccess = false,
|
|
1845
1845
|
toastError = true,
|
|
1846
|
-
showLog = true
|
|
1846
|
+
showLog = true,
|
|
1847
|
+
resFilter,
|
|
1848
|
+
logExtra
|
|
1847
1849
|
} = finalConfig;
|
|
1848
1850
|
const {
|
|
1849
1851
|
log,
|
|
@@ -1859,13 +1861,23 @@ function enhanceWebApi(webApi, apiName) {
|
|
|
1859
1861
|
return new Promise((resolve, reject) => {
|
|
1860
1862
|
webApi(option, finalConfig).then((res) => {
|
|
1861
1863
|
if (showLoading) hideLoadingFn == null ? void 0 : hideLoadingFn();
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1864
|
+
const finalRes = resFilter ? resFilter(res) : res;
|
|
1865
|
+
if (showLog) {
|
|
1866
|
+
const logData = __spreadValues({ name: fname, status: "success", option }, logExtra);
|
|
1867
|
+
if (resFilter) {
|
|
1868
|
+
logData.res = res;
|
|
1869
|
+
logData.resFilter = (0, ts_exports.cloneDeep)(finalRes);
|
|
1870
|
+
} else {
|
|
1871
|
+
logData.res = (0, ts_exports.cloneDeep)(res);
|
|
1872
|
+
}
|
|
1873
|
+
log == null ? void 0 : log("info", logData);
|
|
1874
|
+
}
|
|
1875
|
+
resolve(finalRes);
|
|
1876
|
+
const msg = typeof toastSuccess === "function" ? toastSuccess(finalRes) : toastSuccess;
|
|
1865
1877
|
if (msg) toast == null ? void 0 : toast({ msg, status: "success" });
|
|
1866
1878
|
}).catch((e) => {
|
|
1867
1879
|
if (showLoading) hideLoadingFn == null ? void 0 : hideLoadingFn();
|
|
1868
|
-
if (showLog) log == null ? void 0 : log("error", { name: fname, status: "fail", option, e });
|
|
1880
|
+
if (showLog) log == null ? void 0 : log("error", __spreadValues({ name: fname, status: "fail", option, e }, logExtra));
|
|
1869
1881
|
const msg = typeof toastError === "function" ? toastError(e) : toastError;
|
|
1870
1882
|
if (msg) {
|
|
1871
1883
|
toast == null ? void 0 : toast({
|