mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(fes-cli): 修复window下编译路由配置时路径问题
This commit is contained in:
parent
ac7cd58441
commit
9b29b8e2eb
@ -18,14 +18,14 @@ const isProcessFile = function (path) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isProcessDirectory = function (path, item) {
|
const isProcessDirectory = function (path, item) {
|
||||||
const component = Path.posix.join(path, item);
|
const component = Path.join(path, item);
|
||||||
return fs.statSync(component).isDirectory() && !['components'].includes(item);
|
return fs.statSync(component).isDirectory() && !['components'].includes(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkHasLayout = function (path) {
|
const checkHasLayout = function (path) {
|
||||||
const dirList = fs.readdirSync(path);
|
const dirList = fs.readdirSync(path);
|
||||||
return dirList.some((item) => {
|
return dirList.some((item) => {
|
||||||
if (!isProcessFile(Path.posix.join(path, item))) {
|
if (!isProcessFile(Path.join(path, item))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const ext = Path.extname(item);
|
const ext = Path.extname(item);
|
||||||
@ -66,7 +66,7 @@ const build = function (components, parentRoutes, path, parentRoutePath) {
|
|||||||
}
|
}
|
||||||
dirList.forEach((item) => {
|
dirList.forEach((item) => {
|
||||||
// 文件或者目录的绝对路径
|
// 文件或者目录的绝对路径
|
||||||
const component = Path.posix.join(path, item);
|
const component = Path.join(path, item);
|
||||||
if (isProcessFile(component)) {
|
if (isProcessFile(component)) {
|
||||||
const ext = Path.extname(item);
|
const ext = Path.extname(item);
|
||||||
const fileName = Path.basename(item, ext);
|
const fileName = Path.basename(item, ext);
|
||||||
@ -76,7 +76,7 @@ const build = function (components, parentRoutes, path, parentRoutePath) {
|
|||||||
const routeName = getRouteName(parentRoutePath, fileName);
|
const routeName = getRouteName(parentRoutePath, fileName);
|
||||||
components.push({
|
components.push({
|
||||||
name: routeName,
|
name: routeName,
|
||||||
path: component
|
path: component.replace(/\\/g, '\\\\') // 处理windows兼容性
|
||||||
});
|
});
|
||||||
if (hasLayout) {
|
if (hasLayout) {
|
||||||
if (fileName === 'layout') {
|
if (fileName === 'layout') {
|
||||||
@ -101,7 +101,7 @@ const build = function (components, parentRoutes, path, parentRoutePath) {
|
|||||||
dirList.forEach((item) => {
|
dirList.forEach((item) => {
|
||||||
if (isProcessDirectory(path, item)) {
|
if (isProcessDirectory(path, item)) {
|
||||||
// 文件或者目录的绝对路径
|
// 文件或者目录的绝对路径
|
||||||
const component = Path.posix.join(path, item);
|
const component = Path.join(path, item);
|
||||||
const nextParentRouteUrl = Path.posix.join(parentRoutePath, item);
|
const nextParentRouteUrl = Path.posix.join(parentRoutePath, item);
|
||||||
if (hasLayout) {
|
if (hasLayout) {
|
||||||
build(components, layoutRoute.children, component, nextParentRouteUrl);
|
build(components, layoutRoute.children, component, nextParentRouteUrl);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user