src/router/dynamicRouter.js | ●●●●● patch | view | raw | blame | history |
src/router/dynamicRouter.js
@@ -354,5 +354,17 @@ // currentRoutes.splice(currentRoutes.length, 0, notFound) } console.log('currentRoutes', currentRoutes) router.addRoutes(currentRoutes) const uniqueRoutes = removeDuplicateRoutes(currentRoutes) console.log('uniqueRoutes', uniqueRoutes) router.addRoutes(uniqueRoutes) } function removeDuplicateRoutes(routes) { const routeNames = new Set() return routes.filter(route => { if (routeNames.has(route.path)) { return false // 如果名称已存在,则过滤掉这条路由 } routeNames.add(route.path) // 添加名称到集合中 return true }) }