mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-11 16:46:43 +08:00
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import AESTools from '@/assets/js/utils/cryptoJsUtil'
|
|
import configApp from '@/config'
|
|
import cacheKeys from './needCacheKey'
|
|
export default {
|
|
setLocItem: function(key, value) {
|
|
const exist = cacheKeys.encodeKeys.find(item => {
|
|
return item === key
|
|
})
|
|
//设置localStorage 值
|
|
if (cacheKeys.isAll || exist) {
|
|
window.localStorage.setItem(key, AESTools.AESCacheEncrypt(value, configApp.CACHE_ENCRYP))
|
|
} else {
|
|
window.localStorage.setItem(key, value)
|
|
}
|
|
},
|
|
getLocItem: function(key) {
|
|
// 获取localStorage 中值
|
|
let value = window.localStorage.getItem(key)
|
|
if (value && value != '') {
|
|
const exist = cacheKeys.encodeKeys.find(item => {
|
|
return item === key
|
|
})
|
|
if (cacheKeys.isAll || exist) {
|
|
return AESTools.AESCacheDecrypt(value, configApp.CACHE_ENCRYP)
|
|
}
|
|
}
|
|
return value
|
|
},
|
|
removeLocItem: function(key) {
|
|
// 获取localStorage 中值
|
|
window.localStorage.removeItem(key)
|
|
},
|
|
setSessionItem: function(key, value) {
|
|
//设置sessionStorage 值
|
|
const exist = cacheKeys.encodeKeys.find(item => {
|
|
return item === key
|
|
})
|
|
//设置localStorage 值
|
|
if (cacheKeys.isAll || exist) {
|
|
window.sessionStorage.setItem(key, AESTools.AESCacheEncrypt(value, configApp.CACHE_ENCRYP))
|
|
} else {
|
|
window.sessionStorage.setItem(key, value)
|
|
}
|
|
},
|
|
getSessionItem: function(key) {
|
|
//设置sessionStorage 值
|
|
let value = window.sessionStorage.getItem(key)
|
|
if (value && value != '') {
|
|
const exist = cacheKeys.encodeKeys.find(item => {
|
|
return item === key
|
|
})
|
|
//设置localStorage 值
|
|
if (cacheKeys.isAll || exist) {
|
|
return AESTools.AESCacheDecrypt(value, configApp.CACHE_ENCRYP)
|
|
}
|
|
}
|
|
return value
|
|
}
|
|
}
|