本次提交包含多项功能更新: 1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持 2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储 3. 新增插件分类字段支持,用于场景库分组管理 4. 优化 xq0034/0037/0048 等插件的功能及描述 5. 修复控制面响应兼容问题,支持新旧版本数据格式 6. 新增 xq0033 插件的状态存储模块,用于历史记录管理 7. 优化 CRM 登录窗口模式,支持全屏置顶
113 lines
3.4 KiB
TypeScript
113 lines
3.4 KiB
TypeScript
import * as orm from '@midwayjs/typeorm';
|
|
import {
|
|
Configuration,
|
|
App,
|
|
IMidwayApplication,
|
|
Inject,
|
|
ILogger,
|
|
MidwayWebRouterService,
|
|
} from '@midwayjs/core';
|
|
import * as koa from '@midwayjs/koa';
|
|
// import * as crossDomain from '@midwayjs/cross-domain';
|
|
import * as validate from '@midwayjs/validate';
|
|
import * as info from '@midwayjs/info';
|
|
import * as staticFile from '@midwayjs/static-file';
|
|
import * as cron from '@midwayjs/cron';
|
|
import * as DefaultConfig from './config/config.default';
|
|
import * as LocalConfig from './config/config.local';
|
|
import * as ProdConfig from './config/config.prod';
|
|
import * as cool from '@cool-midway/core';
|
|
import * as upload from '@midwayjs/upload';
|
|
// import * as task from '@cool-midway/task';
|
|
// import * as rpc from '@cool-midway/rpc';
|
|
import { FileserverMonitorService } from './modules/center/service/fileserver-monitor';
|
|
import { CenterLogService } from './modules/center/service/logstore';
|
|
import { CenterRbacService } from './modules/center/service/rbac';
|
|
|
|
@Configuration({
|
|
imports: [
|
|
// https://koajs.com/
|
|
koa,
|
|
// 是否开启跨域(注:顺序不能乱放!!!) http://www.midwayjs.org/docs/extensions/cross_domain
|
|
// crossDomain,
|
|
// 静态文件托管 https://midwayjs.org/docs/extensions/static_file
|
|
staticFile,
|
|
// orm https://midwayjs.org/docs/extensions/orm
|
|
orm,
|
|
// 参数验证 https://midwayjs.org/docs/extensions/validate
|
|
validate,
|
|
// 本地任务 http://www.midwayjs.org/docs/extensions/cron
|
|
cron,
|
|
// 文件上传
|
|
upload,
|
|
// cool-admin 官方组件 https://cool-js.com
|
|
cool,
|
|
// rpc 微服务 远程调用
|
|
// rpc,
|
|
// 任务与队列
|
|
// task,
|
|
{
|
|
component: info,
|
|
enabledEnvironment: ['local', 'prod'],
|
|
},
|
|
],
|
|
importConfigs: [
|
|
{
|
|
default: DefaultConfig,
|
|
local: LocalConfig,
|
|
prod: ProdConfig,
|
|
},
|
|
],
|
|
})
|
|
export class MainConfiguration {
|
|
@App()
|
|
app: IMidwayApplication;
|
|
|
|
@Inject()
|
|
webRouterService: MidwayWebRouterService;
|
|
|
|
@Inject()
|
|
logger: ILogger;
|
|
|
|
async onReady() {
|
|
// 内网文件服务器离线监控(daemon 语义:随进程启停,异常不中断业务)
|
|
const monitor = await this.app.getApplicationContext().getAsync(FileserverMonitorService);
|
|
monitor.start();
|
|
// 集中日志保留期清理(启动清理一次 + 周期清理,随进程启停)
|
|
const logStore = await this.app.getApplicationContext().getAsync(CenterLogService);
|
|
logStore.start();
|
|
// 控制台 RBAC 幂等种子(initDB/initMenu=false,兜底超管角色、业务菜单、运行期账号)
|
|
this.seedRbac();
|
|
}
|
|
|
|
/** RBAC 种子:最多重试 3 次(等数据库连接就绪),失败仅记日志不阻断启动 */
|
|
private seedRbac(attempt = 1) {
|
|
this.app
|
|
.getApplicationContext()
|
|
.getAsync(CenterRbacService)
|
|
.then(rbac => rbac.ensureSeed())
|
|
.catch(e => {
|
|
if (attempt < 3) {
|
|
setTimeout(() => this.seedRbac(attempt + 1), 3000);
|
|
return;
|
|
}
|
|
this.logger.error('[rbac] 控制台权限种子初始化失败:%s', (e as Error)?.message || e);
|
|
});
|
|
}
|
|
|
|
async onStop() {
|
|
try {
|
|
const monitor = await this.app.getApplicationContext().getAsync(FileserverMonitorService);
|
|
monitor.stop();
|
|
} catch (e) {
|
|
/* ignore */
|
|
}
|
|
try {
|
|
const logStore = await this.app.getApplicationContext().getAsync(CenterLogService);
|
|
logStore.stop();
|
|
} catch (e) {
|
|
/* ignore */
|
|
}
|
|
}
|
|
}
|