chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,13 +1,13 @@
import { Config, Provide } from '@midwayjs/core';
import { IMidwayKoaContext, NextFunction, IWebMiddleware } from '@midwayjs/koa';
import { PreviewException } from '@certd/lib-server';
import { Config, Provide } from "@midwayjs/core";
import { IMidwayKoaContext, NextFunction, IWebMiddleware } from "@midwayjs/koa";
import { PreviewException } from "@certd/lib-server";
/**
* 预览模式
*/
@Provide()
export class PreviewMiddleware implements IWebMiddleware {
@Config('preview.enabled')
@Config("preview.enabled")
private preview: boolean;
resolve() {
@@ -24,16 +24,16 @@ export class PreviewMiddleware implements IWebMiddleware {
if (id == null && roleId != null) {
id = roleId;
}
if (id != null && typeof id === 'string') {
if (id != null && typeof id === "string") {
id = parseInt(id);
}
if (url.indexOf('?') !== -1) {
url = url.substring(0, url.indexOf('?'));
if (url.indexOf("?") !== -1) {
url = url.substring(0, url.indexOf("?"));
}
const isModify = url.endsWith('update') || url.endsWith('delete') || url.endsWith('authz');
const isModify = url.endsWith("update") || url.endsWith("delete") || url.endsWith("authz");
const isPreviewId = id < 1000;
if (this.preview && isModify && isPreviewId) {
throw new PreviewException('对不起,预览环境不允许修改此数据,如需体验请添加新数据');
throw new PreviewException("对不起,预览环境不允许修改此数据,如需体验请添加新数据");
}
await next();
return;