在路由权限校验中获取设备列表

This commit is contained in:
白菜
2025-07-23 21:35:40 +08:00
parent b68f2608f3
commit fe14089562
3 changed files with 8 additions and 8 deletions

View File

@ -11,10 +11,6 @@ import ThemePicker from "@/components/ThemePicker"
export default {
name: "App",
components: { ThemePicker },
mounted() {
//获取站点列表
this.$store.dispatch('getZdList')
}
}
</script>
<style scoped>

View File

@ -31,6 +31,7 @@ router.beforeEach((to, from, next) => {
// 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => {
isRelogin.show = false
store.dispatch('getZdList')
store.dispatch('GenerateRoutes').then(accessRoutes => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes) // 动态添加可访问路由表

View File

@ -23,10 +23,13 @@ const ems = {
},
actions: {
getZdList({commit,state}){
return getAllSites().then(response => {
commit('SET_ZD_LIST', response?.data || [])
console.log('store action getZdList 获取站点数据',state.zdList)
})
if(state.zdList.length === 0){
getAllSites().then(response => {
commit('SET_ZD_LIST', response?.data || [])
console.log('store action getZdList 获取站点数据',state.zdList)
})
}
}
}
}