修复从本地缓存中同步获取和移除指定key时因未重新获取本地缓存导致的BUG
This commit is contained in:
parent
3b7b1f21e3
commit
6533168310
@ -6,9 +6,6 @@ let storageKey = 'storage_data'
|
|||||||
// 存储节点变量名
|
// 存储节点变量名
|
||||||
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions]
|
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions]
|
||||||
|
|
||||||
// 存储的数据
|
|
||||||
let storageData = uni.getStorageSync(storageKey) || {}
|
|
||||||
|
|
||||||
const storage = {
|
const storage = {
|
||||||
set: function(key, value) {
|
set: function(key, value) {
|
||||||
if (storageNodeKeys.indexOf(key) != -1) {
|
if (storageNodeKeys.indexOf(key) != -1) {
|
||||||
@ -19,9 +16,11 @@ const storage = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
get: function(key) {
|
get: function(key) {
|
||||||
|
let storageData = uni.getStorageSync(storageKey) || {}
|
||||||
return storageData[key] || ""
|
return storageData[key] || ""
|
||||||
},
|
},
|
||||||
remove: function(key) {
|
remove: function(key) {
|
||||||
|
let storageData = uni.getStorageSync(storageKey) || {}
|
||||||
delete storageData[key]
|
delete storageData[key]
|
||||||
uni.setStorageSync(storageKey, storageData)
|
uni.setStorageSync(storageKey, storageData)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user