fix: configuration problem of first route's path; :bug:
修复:一级路由 path 配置问题;
| | |
| | | import Vue from 'vue' |
| | | import Router from 'vue-router' |
| | | import {formatAuthority} from '@/utils/routerUtil' |
| | | import {formatRoutes} from '@/utils/routerUtil' |
| | | |
| | | Vue.use(Router) |
| | | |
| | |
| | | */ |
| | | function initRouter(isAsync) { |
| | | const options = isAsync ? require('./async/config.async').default : require('./config').default |
| | | formatAuthority(options.routes) |
| | | formatRoutes(options.routes) |
| | | return new Router(options) |
| | | } |
| | | export {loginIgnore, initRouter} |
| | |
| | | if (asyncRoutes) { |
| | | if (routesConfig && routesConfig.length > 0) { |
| | | const routes = parseRoutes(routesConfig, routerMap) |
| | | formatAuthority(routes) |
| | | formatRoutes(routes) |
| | | const finalRoutes = mergeRoutes(router.options.routes, routes) |
| | | router.options = {...router.options, routes: finalRoutes} |
| | | router.matcher = new Router({...router.options, routes:[]}).matcher |
| | |
| | | }) |
| | | } |
| | | return parseRoutesMap(merge) |
| | | } |
| | | |
| | | /** |
| | | * 格式化路由 |
| | | * @param routes 路由配置 |
| | | */ |
| | | function formatRoutes(routes) { |
| | | routes.forEach(route => { |
| | | const {path} = route |
| | | if (!path.startsWith('/') && path !== '*') { |
| | | route.path = '/' + path |
| | | } |
| | | }) |
| | | formatAuthority(routes) |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | export {parseRoutes, loadRoutes, formatAuthority, getI18nKey, loadGuards, deepMergeRoutes} |
| | | export {parseRoutes, loadRoutes, formatAuthority, getI18nKey, loadGuards, deepMergeRoutes, formatRoutes} |