no message
Former-commit-id: cffb2fc3fd9e4c732b4ec46adceafd6728df8d0f Former-commit-id: 688946554293716950dd891134301f2253f8b465 Former-commit-id: ac5933f85b0e18d3f9781d4fb33cc6ab0e39912e
This commit is contained in:
@@ -3,30 +3,28 @@ import VueRouter from 'vue-router'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
// import _path from 'path'
|
||||
import _path2 from 'path-posix'
|
||||
import pathPosix from 'path-posix'
|
||||
import _get from 'lodash.get'
|
||||
// import _replace from 'lodash.replace'
|
||||
|
||||
console.log(_path2)
|
||||
console.log(pathPosix)
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const path2Posix = pathString => pathString.split(_path2.sep).join('/')
|
||||
const path2Posix = pathString => pathString.split(pathPosix.sep).join('/')
|
||||
|
||||
const routesMaker = ({publicPath, namePrefix, req}) => {
|
||||
return req.keys().map(req).map(page => {
|
||||
// 匹配 '/page/'(posix) 或者 '\page\'(win)
|
||||
const pageRegExp = new RegExp(`${_path2.sep}page${_path2.sep}`, 'g')
|
||||
// 每个文件的路径
|
||||
const pagePath = _path2.dirname(page.default.__file)
|
||||
const pagePath = pathPosix.dirname(page.default.__file)
|
||||
console.log('pagePath', pagePath)
|
||||
// 每个文件的路径 => posix 风格
|
||||
const pagePathPosix = path2Posix(pagePath)
|
||||
console.log('pagePathPosix', pagePathPosix)
|
||||
// 路由中使用的路径
|
||||
const path = pagePathPosix.replace(publicPath, '').replace(pageRegExp, _path2.sep)
|
||||
const path = pagePathPosix.replace(publicPath, '').replace(new RegExp(`${pathPosix.sep}page${pathPosix.sep}`, 'g'), pathPosix.sep)
|
||||
console.log('path', path)
|
||||
const name = namePrefix + path.split(_path2.sep).join('-').replace(/-page-/g, '-')
|
||||
const name = namePrefix + path.split(pathPosix.sep).join('-').replace(/-page-/g, '-')
|
||||
return {
|
||||
path: `${path}${_get(page, 'router.pathSuffix', '')}`,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user