Q: 前端接入现有用户系统,waline 未使用最新的 localStorage 用户信息 || Q: The front end is connected to the existing user system, and waline does not use the latest localStorage user information. #2522
Replies: 1 comment 3 replies
-
看情况你是在外部设置了 localStorage,期望 Waline 组件能感知到这块的变化并更新。 It depends on the situation that you have set localStorage externally. It is expected that the Waline component can detect this change and update it. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug | 问题描述
相关讨论:#2334
我试图在我的项目中直接使用 waline,目前已经根据文档实现了一套后端接口并可以正常使用。在前端方面,配置都可以正常处理,并且关闭了登录功能,计划使用直接修改 localStorage 让 waline “认为”用户已登录,并使用对应的鉴权。
现在的问题是:前端修改 localStorage 后,waline 有时候无法实现数据绑定,导致不能及时更新 ui。例如用户在登录页登录后,打开有 waline 的页面,并不能按权限显示正确的图标(删除、编辑等),鉴权的 token 也无法及时更新。
制作了一个 demo:https://stackblitz.com/edit/github-k2jvgx?file=pages%2Fwaline.vue
AUTH_USER
已经更新了,但是 waline 的因为要在打开页面时更新,所以还没有变化WALINE_USER
,然后通过v-if
显示 waline 组件,但是 waline 依然获取不到新的用户信息以上过程中查看请求的 headers,也是没有使用最新的 token 的。
如果打开页面时直接点击上方的 switch user 按钮修改 localStorage,waline 可以及时更新,但切换页面后再切换回来,或者点击 switch show 切换 v-if 的显示之后,就无法实现绑定了。
猜测与 vue 的 useStorage 多方共同使用,和 Waline 组件加载相关,请问是否有解决的办法?
Website URL | 问题网站
1
Where your waline deploy? | 服务部署在哪里?
Other
Where your comment data store? | 数据存储在哪里?
PostgreSQL
Describe the bug | Problem description
Related discussion: #2334
I am trying to use waline directly in my project. Currently, a set of backend interfaces have been implemented according to the documentation and can be used normally. On the front end, the configuration can be processed normally, and the login function is turned off. We plan to directly modify localStorage to make waline "think" the user is logged in and use the corresponding authentication.
The current problem is: after the front end modifies localStorage, waline sometimes cannot implement data binding, resulting in the inability to update the ui in time. For example, after a user logs in on the login page and opens a page with waline, the correct icon (delete, edit, etc.) cannot be displayed according to permissions, and the authentication token cannot be updated in time.
Created a demo: https://stackblitz.com/edit/github-k2jvgx?file=pages%2Fwaline.vue
AUTH_USER
of the user system has been updated, but the waline one has not changed yet because it needs to be updated when the page is opened.WALINE_USER
is updated when the page is loaded, and then the waline component is displayed throughv-if
, but waline still cannot obtain new user information.Checking the headers of the request during the above process also shows that the latest token is not used.
If you directly click the switch user button above to modify localStorage when opening the page, waline can be updated in time, but after switching the page and then switching back, or after clicking switch show to switch the display of v-if, binding cannot be achieved.
I guess it is related to the useStorage of vue, which is used by multiple parties, and is related to the loading of the Waline component. Is there a solution?
Website URL | Problem website
1
Where your waline deploy? | Where is the service deployed?
Other
Where your comment data store? | Where is the data stored?
PostgreSQL
Beta Was this translation helpful? Give feedback.
All reactions