在路由权限校验中获取设备列表
This commit is contained in:
@ -11,10 +11,6 @@ import ThemePicker from "@/components/ThemePicker"
|
||||
export default {
|
||||
name: "App",
|
||||
components: { ThemePicker },
|
||||
mounted() {
|
||||
//获取站点列表
|
||||
this.$store.dispatch('getZdList')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
@ -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) // 动态添加可访问路由表
|
||||
|
||||
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user