if (registerRouteFresh && to.path !== '/login' && to.path !== '/noRight') {
await Http.get('/eoap/menu/list').then(async (res) => {
if (res.data.code === 200) {
userRoutes = res.data.data;
}
if (!userRoutes && userRoutes.length === 0) {
next('/noRight');
} else {
let newRoutes = transformRoute();
const newRoutes = routerInit(userRoutes);
allRoutes.push({
name: 'index',
path: '/',
component: () => import('@/views/index.vue'),
children: newRoutes,
});
allRoutes.forEach((value, index) => {
router.addRoute(value);
});
const notFound = {
path: '/:catchAll(.*)*',
redirect: { name: 'error' },
};
router.addRoute(notFound);
next({ ...to, replace: true });
registerRouteFresh = false;
}
});
} else {
next();
}