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

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 { export default {
name: "App", name: "App",
components: { ThemePicker }, components: { ThemePicker },
mounted() {
//获取站点列表
this.$store.dispatch('getZdList')
}
} }
</script> </script>
<style scoped> <style scoped>

View File

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

View File

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