1.让localStorage值无法修改
window.addEventListener('storage', function () {
localStorage.setItem(e.key, e.oldValue)
});
localStorage里面被篡改的部分 和原来数据 会来回进行切换
2.localStorage值被修改的时候清除他并且跳转到登录页
window.addEventListener('storage', function(e) {
localStorage.clear()
window.location.href = baseRout + '/login.html'
})
3.对 localStorage进行加密和解密
localStorage.setItem('user',window.btoa(window.encodeURIComponent(JSON.stringify(res.data))))
JSON.parse(decodeURIComponent(window.atob(localStorage.getItem('user'))))