From 801658f2905aa5f4d7515f8bd0425c9af4144dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=B9=8F?= Date: Thu, 16 Mar 2023 17:09:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=A8=A1=E5=9D=97=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BAconfig.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/base/service/sys/menu.ts | 42 ++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/modules/base/service/sys/menu.ts b/src/modules/base/service/sys/menu.ts index 01f275c..cf5c5b8 100644 --- a/src/modules/base/service/sys/menu.ts +++ b/src/modules/base/service/sys/menu.ts @@ -268,8 +268,7 @@ export class BaseSysMenuService extends BaseService { 'entity', `${fileName}.ts` ); - this.createFile(entityPath, entity); - // // 生成Controller + // 生成Controller const controllerPath = pathUtil.join( basePath, 'modules', @@ -278,9 +277,48 @@ export class BaseSysMenuService extends BaseService { 'admin', `${fileName}.ts` ); + this.createConfigFile(module); + this.createFile(entityPath, entity); 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