修复从本地缓存中同步获取和移除指定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 storageData = uni.getStorageSync(storageKey) || {}
|
||||
|
||||
const storage = {
|
||||
set: function(key, value) {
|
||||
if (storageNodeKeys.indexOf(key) != -1) {
|
||||
@ -19,9 +16,11 @@ const storage = {
|
||||
}
|
||||
},
|
||||
get: function(key) {
|
||||
let storageData = uni.getStorageSync(storageKey) || {}
|
||||
return storageData[key] || ""
|
||||
},
|
||||
remove: function(key) {
|
||||
let storageData = uni.getStorageSync(storageKey) || {}
|
||||
delete storageData[key]
|
||||
uni.setStorageSync(storageKey, storageData)
|
||||
},
|
||||
@ -30,4 +29,4 @@ const storage = {
|
||||
}
|
||||
}
|
||||
|
||||
export default storage
|
||||
export default storage
|
||||
|
Loading…
Reference in New Issue
Block a user