版本变更V3.29体验优化
This commit is contained in:
@ -84,6 +84,11 @@ export const useUserStore = defineStore('user', () => {
|
||||
localStorage.setItem('refresh_token', data.refresh_token)
|
||||
}
|
||||
|
||||
// [Dify] 登录成功,重新初始化 Dify(Token 变化时 Dify 会开辟新会话,解决会话串号问题)
|
||||
if (typeof window.initDifyChatbot === 'function') {
|
||||
window.initDifyChatbot()
|
||||
}
|
||||
|
||||
// 登录成功后,根据角色获取权限
|
||||
if (role.value) {
|
||||
try {
|
||||
@ -110,6 +115,11 @@ export const useUserStore = defineStore('user', () => {
|
||||
const setToken = (newToken: string) => {
|
||||
token.value = newToken
|
||||
localStorage.setItem('access_token', newToken)
|
||||
|
||||
// [Dify] Token 刷新后,重新初始化 Dify 以更新用户会话
|
||||
if (typeof window.initDifyChatbot === 'function') {
|
||||
window.initDifyChatbot()
|
||||
}
|
||||
}
|
||||
|
||||
// 退出逻辑
|
||||
@ -123,6 +133,11 @@ export const useUserStore = defineStore('user', () => {
|
||||
|
||||
// 2. 清空 LocalStorage (硬盘)
|
||||
localStorage.removeItem('access_token')
|
||||
|
||||
// [Dify] 退出登录时,彻底销毁桌面上的 Dify 聊天窗口,防止信息泄露或报错
|
||||
document.querySelectorAll('[id^="dify-chatbot-"]').forEach(el => el.remove())
|
||||
|
||||
// 清空其他本地存储
|
||||
localStorage.removeItem('refresh_token')
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('role')
|
||||
|
||||
Reference in New Issue
Block a user