mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-16 04:42:49 +00:00
新模块自动创建config.ts
This commit is contained in:
parent
4c9f6dc2c2
commit
801658f290
@ -268,8 +268,7 @@ export class BaseSysMenuService extends BaseService {
|
|||||||
'entity',
|
'entity',
|
||||||
`${fileName}.ts`
|
`${fileName}.ts`
|
||||||
);
|
);
|
||||||
this.createFile(entityPath, entity);
|
// 生成Controller
|
||||||
// // 生成Controller
|
|
||||||
const controllerPath = pathUtil.join(
|
const controllerPath = pathUtil.join(
|
||||||
basePath,
|
basePath,
|
||||||
'modules',
|
'modules',
|
||||||
@ -278,9 +277,48 @@ export class BaseSysMenuService extends BaseService {
|
|||||||
'admin',
|
'admin',
|
||||||
`${fileName}.ts`
|
`${fileName}.ts`
|
||||||
);
|
);
|
||||||
|
this.createConfigFile(module);
|
||||||
|
this.createFile(entityPath, entity);
|
||||||
this.createFile(controllerPath, controller);
|
this.createFile(controllerPath, controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建配置文件
|
||||||
|
* @param module
|
||||||
|
*/
|
||||||
|
async createConfigFile(module: string) {
|
||||||
|
const basePath = this.app.getBaseDir();
|
||||||
|
const configFilePath = pathUtil.join(
|
||||||
|
basePath,
|
||||||
|
'modules',
|
||||||
|
module,
|
||||||
|
'config.ts'
|
||||||
|
);
|
||||||
|
if (!fs.existsSync(configFilePath)) {
|
||||||
|
const data = `import { ModuleConfig } from '@cool-midway/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块配置
|
||||||
|
*/
|
||||||
|
export default () => {
|
||||||
|
return {
|
||||||
|
// 模块名称
|
||||||
|
name: 'xxx',
|
||||||
|
// 模块描述
|
||||||
|
description: 'xxx',
|
||||||
|
// 中间件,只对本模块有效
|
||||||
|
middlewares: [],
|
||||||
|
// 中间件,全局有效
|
||||||
|
globalMiddlewares: [],
|
||||||
|
// 模块加载顺序,默认为0,值越大越优先加载
|
||||||
|
order: 0,
|
||||||
|
} as ModuleConfig;
|
||||||
|
};
|
||||||
|
`;
|
||||||
|
await this.createFile(configFilePath, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 找到文件名
|
* 找到文件名
|
||||||
* @param controller
|
* @param controller
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user