etherreq 1.1.4 → 1.1.6
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/package.json +1 -1
- package/src/request.js +6 -5
package/package.json
CHANGED
package/src/request.js
CHANGED
|
@@ -44,19 +44,20 @@ instance.interceptors.request.use((config) => {
|
|
|
44
44
|
|
|
45
45
|
// 响应拦截器:自动提取 response.data 并写入缓存
|
|
46
46
|
instance.interceptors.response.use(
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
if (
|
|
50
|
-
//
|
|
51
|
-
return response;
|
|
47
|
+
(response) => {
|
|
48
|
+
// 如果是缓存命中,直接返回 cached 数据
|
|
49
|
+
if (response && response.isFromCache) {
|
|
50
|
+
return response.data; // ✅ 返回 cached 数据
|
|
52
51
|
}
|
|
53
52
|
|
|
53
|
+
// 否则正常处理 response.data
|
|
54
54
|
const config = response.config;
|
|
55
55
|
|
|
56
56
|
if (config && config.method === 'GET' && !config.disableCache) {
|
|
57
57
|
const cacheKey = getCacheKey(config.url, config);
|
|
58
58
|
requestCache.set(cacheKey, response.data);
|
|
59
59
|
}
|
|
60
|
+
|
|
60
61
|
return response.data;
|
|
61
62
|
},
|
|
62
63
|
(error) => {
|