From 64f1a1f9a47cf412336c9cd0da55f06bd4516b38 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Wed, 6 Jun 2018 16:59:50 +0800 Subject: [PATCH] no message Former-commit-id: 07e067f222534f69801f90f79963c9538b90c06a Former-commit-id: c94da06568a016bb4e170d0ff998127d3be54f42 Former-commit-id: d87bed1fbda898cdbbd5f1e40f0a2306b08784ac --- src/router/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index ed916870..4a4a8844 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -10,20 +10,25 @@ Vue.use(VueRouter) const routesMaker = ({publicPath, namePrefix, req}) => { const win2posix = pathString => pathString.split('\\').join('/') return req.keys().map(req).map(page => { - // 每个文件的路径 + // 每个文件的路径 已经转换为 posix const pagePath = pathPosix.dirname(win2posix(page.default.__file)) // 路由中使用的路径 const path = pagePath .replace(win2posix(publicPath), '') - .replace(new RegExp(`${pathPosix.sep}page${pathPosix.sep}`, 'g'), pathPosix.sep) - const name = namePrefix + path.split(pathPosix.sep).join('-').replace(/-page-/g, '-') - return { + .replace(new RegExp('/page/', 'g'), '/') + const name = `${namePrefix}${path.split('/').join('-')}` + const route = { path: `${path}${_get(page, 'router.pathSuffix', '')}`, name, ...page.router, meta: { requiresAuth: true }, component: page.default } + console.log(JSON.stringify({ + path: route.path, + name: route.name + })) + return route }) }