微调编译router时,判断pages下文件不存在的情况
This commit is contained in:
parent
da9adea2e6
commit
ebee33492b
|
|
@ -26,8 +26,9 @@ function addFileWatcher(filename, nss) {
|
||||||
else {
|
else {
|
||||||
routerFiles[ns] = [filename];
|
routerFiles[ns] = [filename];
|
||||||
const pageSrcDir = join(AppPaths.appRootSrc, 'pages', ns);
|
const pageSrcDir = join(AppPaths.appRootSrc, 'pages', ns);
|
||||||
|
const isExists = fs.existsSync(pageSrcDir);
|
||||||
NodeWatch(pageSrcDir, { recursive: true }, (evt, name) => {
|
if (isExists) {
|
||||||
|
NodeWatch(pageSrcDir, { recursive: true }, (evt, name) => {
|
||||||
const { dir } = parse(name);
|
const { dir } = parse(name);
|
||||||
const indexJsonFile = join(dir, 'index.json');
|
const indexJsonFile = join(dir, 'index.json');
|
||||||
const indexTsxFile = join(dir, 'index.tsx');
|
const indexTsxFile = join(dir, 'index.tsx');
|
||||||
|
|
@ -66,7 +67,9 @@ function addFileWatcher(filename, nss) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -128,33 +131,41 @@ function traversePages(nss) {
|
||||||
|
|
||||||
const traverse = (dir, relativePath) => {
|
const traverse = (dir, relativePath) => {
|
||||||
const files = fs.readdirSync(dir);
|
const files = fs.readdirSync(dir);
|
||||||
files.forEach(
|
files.forEach((file) => {
|
||||||
(file) => {
|
const filepath = join(dir, file);
|
||||||
const filepath = join(dir, file);
|
const stat = fs.statSync(filepath);
|
||||||
const stat = fs.statSync(filepath);
|
if (
|
||||||
if (stat.isFile() && ['index.tsx', 'web.tsx', 'web.pc.tsx'].includes(file) && !pageFiles[ns].hasOwnProperty(dir)) {
|
stat.isFile() &&
|
||||||
const indexJsonFile = join(dir, 'index.json');
|
['index.tsx', 'web.tsx', 'web.pc.tsx'].includes(
|
||||||
let oakDisablePulldownRefresh = false;
|
file
|
||||||
if (fs.existsSync(indexJsonFile)) {
|
) &&
|
||||||
const {
|
!pageFiles[ns].hasOwnProperty(dir)
|
||||||
enablePullDownRefresh = true,
|
) {
|
||||||
} = require(indexJsonFile);
|
const indexJsonFile = join(dir, 'index.json');
|
||||||
oakDisablePulldownRefresh = !enablePullDownRefresh;
|
let oakDisablePulldownRefresh = false;
|
||||||
}
|
if (fs.existsSync(indexJsonFile)) {
|
||||||
pageFiles[ns][dir] = {
|
const {
|
||||||
path: relativePath.replace(/\\/g, '/'),
|
enablePullDownRefresh = true,
|
||||||
oakDisablePulldownRefresh,
|
} = require(indexJsonFile);
|
||||||
}
|
oakDisablePulldownRefresh =
|
||||||
}
|
!enablePullDownRefresh;
|
||||||
else if (stat.isDirectory()) {
|
|
||||||
const dir2 = join(dir, file);
|
|
||||||
const relativePath2 = join(relativePath, file);
|
|
||||||
traverse(dir2, relativePath2);
|
|
||||||
}
|
}
|
||||||
|
pageFiles[ns][dir] = {
|
||||||
|
path: relativePath.replace(/\\/g, '/'),
|
||||||
|
oakDisablePulldownRefresh,
|
||||||
|
};
|
||||||
|
} else if (stat.isDirectory()) {
|
||||||
|
const dir2 = join(dir, file);
|
||||||
|
const relativePath2 = join(relativePath, file);
|
||||||
|
traverse(dir2, relativePath2);
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
};
|
};
|
||||||
traverse(pageSrcDir, '');
|
const isExists = fs.existsSync(pageSrcDir);
|
||||||
|
if (isExists) {
|
||||||
|
traverse(pageSrcDir, '');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue