| | |
| | | import { RoutesAlias } from '../routesAlias' |
| | | import { RoutesAlias } from '../routesAlias.js' |
| | | class RouteValidator { |
| | | constructor() { |
| | | this.warnedRoutes = new Set() |
| | |
| | | */ |
| | | checkDuplicates(routes, errors, warnings, parentPath = '') { |
| | | const routeNameMap = /* @__PURE__ */ new Map() |
| | | const routePathMap = /* @__PURE__ */ new Map() |
| | | const componentPathMap = /* @__PURE__ */ new Map() |
| | | const checkRoutes = (routes2, parentPath2 = '') => { |
| | | routes2.forEach((route) => { |
| | | const currentPath = route.path || '' |
| | | const fullPath = this.resolvePath(parentPath2, currentPath) |
| | | if (fullPath) { |
| | | if (routePathMap.has(fullPath)) { |
| | | warnings.push(`路由路径重复: "${fullPath}"`) |
| | | } else { |
| | | routePathMap.set(fullPath, String(route.name || fullPath)) |
| | | } |
| | | } |
| | | if (route.name) { |
| | | const routeName = String(route.name) |
| | | if (routeNameMap.has(routeName)) { |