diff --git a/package.json b/package.json index d961694..89450b1 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "mwtsc": "^1.15.1", "pkg": "^5.8.1", "ts-jest": "^29.2.5", - "typescript": "~5.7.3" + "typescript": "~5.7.3", + "rimraf": "^5.0.5" }, "engines": { "node": ">=18.0.0" @@ -48,7 +49,7 @@ "scripts": { "start": "NODE_ENV=production node ./bootstrap.js", "entity": "cool entity", - "dev": "cool check entity && bundle && cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app.js", + "dev": "cool check entity && cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app.js", "test": "cross-env NODE_ENV=unittest jest", "cov": "jest --coverage", "lint": "mwts check", @@ -56,7 +57,7 @@ "ci": "npm run cov", "build": "cool entity && bundle && mwtsc --cleanOutDir", "build:obfuscate": "cool entity && bundle && mwtsc --cleanOutDir && cool obfuscate", - "pkg": "npm run build && pkg . -d > build/pkg.log", + "pkg": "rimraf build && mkdir build && npm run build && pkg . -d > build/pkg.log", "pm2:start": "pm2 start ./bootstrap.js -i 1 --name cool-admin", "pm2:stop": "pm2 stop cool-admin & pm2 delete cool-admin" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ce3bd7..a6d3c9e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,9 @@ importers: pkg: specifier: ^5.8.1 version: 5.8.1 + rimraf: + specifier: ^5.0.5 + version: 5.0.10 ts-jest: specifier: ^29.2.5 version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@22.10.5))(typescript@5.7.3) diff --git a/public/welcome.html b/public/index.html similarity index 84% rename from public/welcome.html rename to public/index.html index 063bf0b..f729840 100644 --- a/public/welcome.html +++ b/public/index.html @@ -8,8 +8,8 @@ COOL-AMIND 一个很酷的后台权限管理系统 - - + +
HELLO COOL-ADMIN AI快速开发框架
@@ -24,7 +24,7 @@ - + diff --git a/src/config/config.default.ts b/src/config/config.default.ts index 4216243..f8d6519 100644 --- a/src/config/config.default.ts +++ b/src/config/config.default.ts @@ -19,13 +19,6 @@ export default { prefix: '/public', dir: path.join(__dirname, '..', '..', 'public'), }, - welcome: { - prefix: '/', - dir: path.join(__dirname, '..', '..', 'public'), - alias: { - '/': '/welcome.html', - }, - }, }, }, // 文件上传 diff --git a/src/config/config.local.ts b/src/config/config.local.ts index c7a38fd..f15c2f6 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -1,6 +1,5 @@ import { CoolConfig } from '@cool-midway/core'; import { MidwayConfig } from '@midwayjs/core'; -import { entities } from '../entities'; /** * 本地开发 npm run dev 读取的配置文件 @@ -24,7 +23,7 @@ export default { // 是否开启缓存 cache: true, // 实体路径 - entities, + entities: ['**/modules/*/entity'], // 扩展配置 extra: { keepAliveInitialDelay: 10000, diff --git a/src/configuration.ts b/src/configuration.ts index b27ea79..79bd789 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -5,6 +5,7 @@ import { IMidwayApplication, Inject, ILogger, + MidwayWebRouterService, } from '@midwayjs/core'; import * as koa from '@midwayjs/koa'; // import * as crossDomain from '@midwayjs/cross-domain'; @@ -53,8 +54,21 @@ export class MainConfiguration { @App() app: IMidwayApplication; + @Inject() + webRouterService: MidwayWebRouterService; + @Inject() logger: ILogger; - async onReady() {} + async onReady() { + this.webRouterService.addRouter( + async ctx => { + ctx.redirect('/public/index.html'); + }, + { + url: '/', + requestMethod: 'GET', + } + ); + } } diff --git a/src/index.ts b/src/index.ts index 1dcc7ea..def1566 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ export { MainConfiguration as Configuration } from './configuration'; export * from './comm/utils'; export * from './config/config.default'; +export * from './config/config.local'; export * from './modules/base/entity/sys/user_role'; export * from './modules/base/entity/sys/user'; export * from './modules/base/entity/sys/role_menu'; @@ -13,7 +14,6 @@ export * from './modules/base/entity/sys/log'; export * from './modules/base/entity/sys/department'; export * from './modules/base/entity/sys/conf'; export * from './entities'; -export * from './config/config.local'; export * from './config/config.prod'; export * from './interface'; export * from './modules/base/service/sys/conf';