fix: 同步退出登录后再登录不同权限账号时菜单不更新问题

This commit is contained in:
lilinyuan
2024-03-31 00:23:31 +08:00
parent 7e0a065944
commit ed0a5e1a7d
2 changed files with 10 additions and 1 deletions

View File

@@ -27,8 +27,10 @@ import Hamburger from './Hamburger.vue';
import {useAuthStore} from '@/stores/userstore.js' import {useAuthStore} from '@/stores/userstore.js'
import BellSocket from "./BellSocket.vue"; import BellSocket from "./BellSocket.vue";
import {getUserInfo} from "../../api/login"; import {getUserInfo} from "../../api/login";
import {usePermisstionStroe} from '@/stores/permisstion'
const authStore = useAuthStore() const authStore = useAuthStore()
const permisstionStore = usePermisstionStroe()
const userInfo = ref({}) const userInfo = ref({})
const visitedP = ref(false) const visitedP = ref(false)
const router = useRouter() const router = useRouter()
@@ -58,6 +60,7 @@ const handleToAuth = () => {
const handleLogout = () => { const handleLogout = () => {
visitedP.value = !visitedP.value visitedP.value = !visitedP.value
authStore.userLogout() authStore.userLogout()
permisstionStore.removeMenu()
router.push('/login') router.push('/login')
} }
</script> </script>

View File

@@ -96,12 +96,18 @@ export const usePermisstionStroe = defineStore('permisstion', () => {
} }
} }
const removeMenu = () => {
menuList.value.length = 0
asyncRouters.value.length = 0
}
return { return {
asyncRouters, asyncRouters,
menuList, menuList,
isLoadRoutes, isLoadRoutes,
setAsyncRouters, setAsyncRouters,
setIsLoadRoutes setIsLoadRoutes,
removeMenu
} }
}) })