-
Notifications
You must be signed in to change notification settings - Fork 210
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
fix: 修复 store 中并未对 localStorage 的 TOKEN_NAME 键进行赋值的缺陷 #504
Conversation
持久化用的应该是pinia-plugin-persistedstate插件,开启persist之后会对值默认保存到localStorage中,但为什么没有指定TOKEN_NAME确实有一点奇怪 |
也许一开始没做持久化处理,那时token手动存localStorage |
|
你是说删除手动存储 |
|
@uyarn 有空了麻烦看下这个token没有携带后端的问题,还有 |
建议而已,其实两种写法都没问题。只是说使用persist插件改造成SSR会更方便一点。 |
第一个问题没处理好 agree 第二个问题 我觉得很难定义吧 暂时不改动了 |
@uyarn 我觉得他的key和paths定义写反了 |
* perf: 路由守卫获取菜单异常,跳转登录页并弹窗提示 (#502) * perf: 规范不同系统中的结束符 (#505) * fix: eol * fix: 测试效果 * fix: 默认全部文件eol=lf * fix: 防止误判,仅对部分明确的文件设置 * fix: 新建文件eol格式错误进行互补 * Update settings.json * fix: 修复无法将通知设为未读 (#511) * fix: 修复 store 中并未对 localStorage 的 TOKEN_NAME 键进行赋值的缺陷 (#504) * fix: 接口请求不携带token * fix: 优化token持久化策略 * fix: 删除多余的log * chore: release 0.7.5 (#512) --------- Co-authored-by: liweijie0812 <674416404@qq.com> Co-authored-by: Gui.H <springhgui@outlook.com> Co-authored-by: You <i@izoyo.cn>
🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
底层携带

token
从localStorage
中获取token
,而store
中并未对localStorage
的TOKEN_NAME
键进行赋值,sotore
做了持久化,亦可修改下面的获取方式从userStore
中获取另外,这里默认开启

withCredentials
则在跨域请求时对后端的安全性要求更高,强制要求Access-Control-Allow-Origin
必须返回当前域,axios
组件该参数默认貌似是关闭的,是否应该当开发者明确自己的需求必须携带cookie时主动打开该配置,而不是默认开启,因为大部分项目应该不需要携带cookie。以上属于个人简单测试后的拙见,仅供参考
📝 更新日志
fix: 修复 store 中并未对 localStorage 的 TOKEN_NAME 键进行赋值的缺陷
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单