-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: user logout #91
Conversation
✅ Deploy Preview for vue-hbs-admin ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
可以在退出成功后随便给一个什么反馈都可以,例如一个 message.success,增强一下交互感 |
退出之后直接会返回登录界面,本身就是交互了,你觉得呢 |
这个可以有 |
现在有封装了message组件吗,要不要先提个issue |
没有,先直接用 antdv 的 message 吧 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setCache 和 getCache 对 value 的操作要优化一下
setCache(key: string, value: any) {
if (value) {
window.localStorage.setItem(key, JSON.stringify(value))
}
else {
window.localStorage.removeItem(key)
}
} 在 utils 中通过 value 决定是 setItem 还是 removeItem,是不合适的,更建议在你需要移除 cache 的地方调用 removeCache 来实现删除。 |
我之前使用{value:xxx},以及现在判断undefined是进行removeItem删除主要是防止以下问题:
改成下面这种吗?我不知道我理解的对不对 setCache(key: string, value: any) {
if (value) {
window.localStorage.setItem(key, JSON.stringify(value))
}
else {
this.removeCache(key)
}
} |
在 你可以在退出登录的时候,直接调用 localCache.removeCache(token),来实现删除操作,更合理一些,而不是修改 LocalCache 类的方法来实现。 不知道这样说,你可以理解不 |
我懂你的意思了,我上面说了,如果setCache进去了undefined值,getCache里调用JSON.parse会有异常,这种边界状态你觉得如何处理比较好。 |
setCache 的时候有一个 if 判断,如果是 undefined 就不会保存了 |
不保存是可以,如果之前有值就不能替换了。所以还对{value:xx}方式合适 |
当你需要把保存的值变成空的时候,就调用 removeCache。 为什么不用 { value: xxx } 的形式? 如果你在控制台查看存储在本地的数据,外层都包裹一个 { value: xxx },你会不会很烦躁? |
Description
{value}
,避免value值为undefined时JSON.parse报错close #53
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).