fix: 修复左侧菜单收起时无法展开子菜单的bug

This commit is contained in:
xiaojunnuo
2024-12-24 17:09:06 +08:00
parent 8ebf95a222
commit 005622307e
21 changed files with 367 additions and 172 deletions
@@ -72,7 +72,7 @@ const development = {
type: 'better-sqlite3',
database: './data/db.sqlite',
synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true
logging: true,
logging: false,
highlightSql: false,
// 配置实体模型 或者 entities: '/entity',
@@ -1,7 +1,7 @@
import { Provide } from '@midwayjs/core';
import { IWebMiddleware, IMidwayKoaContext, NextFunction } from '@midwayjs/koa';
import { logger } from '@certd/basic';
import { Result } from '@certd/lib-server';
import { BaseException, Result } from '@certd/lib-server';
@Provide()
export class GlobalExceptionMiddleware implements IWebMiddleware {
@@ -14,7 +14,11 @@ export class GlobalExceptionMiddleware implements IWebMiddleware {
await next();
logger.info('请求完成:', url, Date.now() - startTime + 'ms');
} catch (err) {
logger.error('请求异常:', url, Date.now() - startTime + 'ms', err);
logger.error('请求异常:', url, Date.now() - startTime + 'ms', err.message);
if (!(err instanceof BaseException)) {
logger.error(err);
}
ctx.status = 200;
if (err.code == null || typeof err.code !== 'number') {
err.code = 1;
@@ -148,7 +148,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
return new PipelineDetail(pipeline);
}
async update(bean: PipelineEntity) {
async update(bean: Partial<PipelineEntity>) {
//更新非trigger部分
await super.update(bean);
}
@@ -304,13 +304,17 @@ export class PipelineService extends BaseService<PipelineEntity> {
}
async trigger(id: any, stepId?: string) {
const entity: PipelineEntity = await this.info(id);
if (isComm()) {
await this.checkHasDeployCount(id, entity.userId);
}
this.cron.register({
name: `pipeline.${id}.trigger.once`,
cron: null,
job: async () => {
logger.info('用户手动启动job');
try {
await this.run(id, null, stepId);
await this.doRun(entity, null, stepId);
} catch (e) {
logger.error('手动job执行失败:', e);
}
@@ -318,6 +322,21 @@ export class PipelineService extends BaseService<PipelineEntity> {
});
}
async checkHasDeployCount(pipelineId: number, userId: number) {
try {
return await this.userSuiteService.checkHasDeployCount(userId);
} catch (e) {
if (e instanceof NeedSuiteException) {
logger.error(e.message);
await this.update({
id: pipelineId,
status: 'no_deploy_count',
});
}
throw e;
}
}
async delete(id: any) {
await this.clearTriggers(id);
//TODO 删除storage
@@ -390,10 +409,14 @@ export class PipelineService extends BaseService<PipelineEntity> {
async run(id: number, triggerId: string, stepId?: string) {
const entity: PipelineEntity = await this.info(id);
await this.doRun(entity, triggerId, stepId);
}
async doRun(entity: PipelineEntity, triggerId: string, stepId?: string) {
const id = entity.id;
let suite: UserSuiteEntity = null;
if (isComm()) {
suite = await this.userSuiteService.checkHasDeployCount(entity.userId);
suite = await this.checkHasDeployCount(id, entity.userId);
}
const pipeline = JSON.parse(entity.content);