mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-13 04:56:44 +08:00
安全性问题处理:代码版本整理 初始版本1 --提交人:阳华祥
This commit is contained in:
59
src/assets/js/utils/cacheUtils.js
Normal file
59
src/assets/js/utils/cacheUtils.js
Normal file
@@ -0,0 +1,59 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user