fix(cache): 修复promise模式下cache能力不生效的问题

This commit is contained in:
ivinwu
2022-07-05 20:31:29 +08:00
parent 2551a487d1
commit dc55e9a2b0
5 changed files with 11 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<p align="center"><img src="./image/logo.png" alt="weRequest" height="160"/></p> <p align="center"><img src="./image/logo.png" alt="weRequest" height="160"/></p>
<h2 align="center">v1.6.0</h2> <h2 align="center">v1.6.1</h2>
<p align="center"><b>解决繁琐的小程序会话管理,一款自带登录态管理的网络请求组件。</b></p> <p align="center"><b>解决繁琐的小程序会话管理,一款自带登录态管理的网络请求组件。</b></p>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "we-request", "name": "we-request",
"version": "1.6.0", "version": "1.6.1",
"description": "本工具通过拓展小程序的wx.request让开发者通过简单的配置实现自动管理登录态等功能", "description": "本工具通过拓展小程序的wx.request让开发者通过简单的配置实现自动管理登录态等功能",
"keywords": [ "keywords": [
"登录态", "登录态",

View File

@@ -44,6 +44,8 @@ function responseForRequest(
realData = res.data; realData = res.data;
} }
} catch (e) {} } catch (e) {}
// 缓存存储
cacheManager.set(obj, realData);
if (!obj.noCacheFlash) { if (!obj.noCacheFlash) {
// 如果为了保证页面不闪烁,则不回调,只是缓存最新数据,待下次进入再用 // 如果为了保证页面不闪烁,则不回调,只是缓存最新数据,待下次进入再用
if (typeof obj.success === "function") { if (typeof obj.success === "function") {
@@ -52,8 +54,6 @@ function responseForRequest(
return realData; return realData;
} }
} }
// 缓存存储
cacheManager.set(obj, realData);
} else { } else {
// 接口返回失败码 // 接口返回失败码
throw { type: 'logic-error', res } throw { type: 'logic-error', res }