xdoer / PreQuest

A Modular And Pluggable Solution For HTTP Request.
https://pre-quest.vercel.app
MIT License
87 stars 14 forks source link

还是uniapp 缓存的问题, #35

Closed ayhome closed 2 years ago

ayhome commented 2 years ago

缓存控制器这样来写

cacheKernel() {
return {
get:function(key) {
let resq = uni.getStorageSync(key)
if(!resq) return false;
return resq;
},
// set: uni.setStorageSync,
set: function(key,resq){
uni.setStorageSync(key,resq);
},
delete: function(key){
return uni.removeStorageSync(key)
}
}
},

但是返回的是空 ` prequest.post(url, args).then(res => {
console.log(res); // {} 这里是空

}).then(res => {

})
`

xdoer commented 2 years ago

非常抱歉,源代码里有个 Bug,一时半会儿还解决不了。。你这里具体需求是什么?我可以帮你先出出主意

ayhome commented 2 years ago

非常抱歉,源代码里有个 Bug,一时半会儿还解决不了。。你这里具体需求是什么?我可以帮你先出出主意

不急,等你修复再更新,我自己也有折中办法,不过你框架刚好符合我需求,

xdoer commented 2 years ago

Bug 是由 中间件里的 return 引起的,根据目前的项目架构,缓存的功能只能做到 adapter 的 request 请求方法前,在这里使用缓存取数据,然后进行 promise 的 resolve。。你可以把 @prequest/miniprogram 的源码拷贝到你项目里,自己尝试改改

xdoer commented 2 years ago

想到了一个办法处理缓存 https://pre-quest.vercel.app/#/cache