refactor(plugin-model): 优化下代码,只判定src/models下的文件为模块数据

This commit is contained in:
万纯 2021-03-25 16:04:02 +08:00
parent 77e074d03a
commit d828b16ce9
2 changed files with 9 additions and 9 deletions

View File

@ -24,12 +24,12 @@ export default (api) => {
function getAllModels() {
const srcModelsPath = getModelsPath();
return lodash.uniq([
...getModels(srcModelsPath),
...getModels(
paths.absPagesPath,
`**/${getModelDir()}/**/*.{js,jsx}`
),
...getModels(paths.absPagesPath, '**/*.model.{js,jsx}')
...getModels(srcModelsPath)
// ...getModels(
// paths.absPagesPath,
// `**/${getModelDir()}/**/*.{js,jsx}`
// ),
// ...getModels(paths.absPagesPath, '**/*.model.{js,jsx}')
]);
}

View File

@ -24,11 +24,11 @@ function getExtraImports(models = [], absSrcPath) {
.map((ele) => {
if (ele.exportName) {
return `import { ${ele.exportName} } from '${winPath(
ele.importPath.replace(/'/g, "\\'"),
ele.importPath.replace(/'/g, "\\'")
)}';`;
}
return `import ${ele.importName} from '${winPath(
ele.importPath.replace(/'/g, "\\'"),
ele.importPath.replace(/'/g, "\\'")
)}';`;
})
.join(EOL);
@ -37,7 +37,7 @@ function getExtraImports(models = [], absSrcPath) {
export const getTmpFile = (
files,
extra = [],
absSrcPath,
absSrcPath
) => {
const userImports = genImports(files);
const userModels = getModels(files, absSrcPath);