refactor: 清理冗余代码并修复提示文案

This commit is contained in:
Nixevol
2026-07-05 08:55:32 +08:00
parent a0ccf3805b
commit 7ac43cf96b
6 changed files with 17 additions and 18 deletions
+1
View File
@@ -4,6 +4,7 @@ Desktop.ini
# Logs # Logs
*.log *.log
.dev-run.pid
# Environment files # Environment files
.env .env
+1
View File
@@ -169,6 +169,7 @@
- 系统设置两列稳定布局(2026-07-05):系统设置上方卡片区固定两列显示,不再因浏览器缩小自动变成单列;平台设置卡片约 448px,日志设置和备份策略卡片统一约 376px。卡片内字段行使用固定标签列 + 12px 间距 + 固定控件列(平台卡片标签列 148px,右侧卡片标签列 128px),保证同一卡片内标题左侧、输入框/选择框起点对齐。中文“客户端轮播间隔(秒)”改为“客户端轮播间隔”,英文设置字段也同步缩短以适配紧凑布局。 - 系统设置两列稳定布局(2026-07-05):系统设置上方卡片区固定两列显示,不再因浏览器缩小自动变成单列;平台设置卡片约 448px,日志设置和备份策略卡片统一约 376px。卡片内字段行使用固定标签列 + 12px 间距 + 固定控件列(平台卡片标签列 148px,右侧卡片标签列 128px),保证同一卡片内标题左侧、输入框/选择框起点对齐。中文“客户端轮播间隔(秒)”改为“客户端轮播间隔”,英文设置字段也同步缩短以适配紧凑布局。
- 系统设置滚动修复(2026-07-05):系统设置页恢复为占满后台内容区固定高度,外层 `.settings-page` 隐藏溢出,避免和主布局同时产生双滚动条;滚动职责集中到 `.settings-content`,在浏览器高度不足时只出现一根设置内容滚动条。备份与恢复面板固定最小高度 320px,备份表格保留至少 180px,可保证低高度下备份列表和分页仍可见。 - 系统设置滚动修复(2026-07-05):系统设置页恢复为占满后台内容区固定高度,外层 `.settings-page` 隐藏溢出,避免和主布局同时产生双滚动条;滚动职责集中到 `.settings-content`,在浏览器高度不足时只出现一根设置内容滚动条。备份与恢复面板固定最小高度 320px,备份表格保留至少 180px,可保证低高度下备份列表和分页仍可见。
- Docker 全栈脚本与编排体检修复(2026-07-05):`docker_build.py` / `docker_dev.py` 改用 `build_full_stack_env()` 生成适合 Nginx 全栈拓扑的 `.env`,本机演示时后台和短链入口为 `http://localhost`,客户端为 `http://localhost:8080`,短链跳转模板为 `http://localhost:8080/#/trace/{code}`,避免沿用开发端口 `3000/5174` 导致二维码/短链不可用。`docker-compose.full.yml` 补齐 API 实际读取的 `JWT_EXPIRES_IN`、`PUBLIC_TRACE_PATH`、`ADMIN_ORIGIN`、`TRACE_URL_TEMPLATE`、`STORAGE_*`、`CDN_BASE_URL`、`BACKUP_DIR`、`OSS_*`、`TIANHE_*` 等环境变量,并新增 `artveris_backups` 独立卷持久化非公开备份包。开发/全栈 Redis 服务都按 `REDIS_PASSWORD` 条件启用 `requirepass`,保证配置 Redis 密码时容器端和 API 端一致。 - Docker 全栈脚本与编排体检修复(2026-07-05):`docker_build.py` / `docker_dev.py` 改用 `build_full_stack_env()` 生成适合 Nginx 全栈拓扑的 `.env`,本机演示时后台和短链入口为 `http://localhost`,客户端为 `http://localhost:8080`,短链跳转模板为 `http://localhost:8080/#/trace/{code}`,避免沿用开发端口 `3000/5174` 导致二维码/短链不可用。`docker-compose.full.yml` 补齐 API 实际读取的 `JWT_EXPIRES_IN`、`PUBLIC_TRACE_PATH`、`ADMIN_ORIGIN`、`TRACE_URL_TEMPLATE`、`STORAGE_*`、`CDN_BASE_URL`、`BACKUP_DIR`、`OSS_*`、`TIANHE_*` 等环境变量,并新增 `artveris_backups` 独立卷持久化非公开备份包。开发/全栈 Redis 服务都按 `REDIS_PASSWORD` 条件启用 `requirepass`,保证配置 Redis 密码时容器端和 API 端一致。
- 代码清理与回归体检(2026-07-05):清理 API 中明确未使用的局部变量/导入/常量(证书更新、出库导入、追溯码服务),修复 `TraceCodeService` 中残留的乱码业务提示文案;根 `package.json` 去掉重复的 `esbuild` 构建白名单项;`.gitignore` 新增 `.dev-run.pid`,避免开发服务 PID 临时文件入库。已执行四个包 `tsc --noUnusedLocals --noUnusedParameters`、`pnpm -r build`、`pnpm --filter @artveris/api test`、`docker compose ... config --quiet`(dev/full 两套)和接口烟测,均通过;重启 `scripts/dev.py --auto --yes --no-seed` 后 API/admin/client 端口正常。Codex 内置浏览器已回归后台看板、模板、艺术品档案、追溯码管理、出库、审核、查询日志、操作日志、用户、系统设置、个人信息,以及客户端追溯页,未见前端控制台 error。Windows/PowerShell 下读取 UTF-8 日志时可能显示中文乱码,但源文件内容正常;Node 24 下启动 watch 服务会出现依赖工具链触发的 `DEP0190` 警告,当前不影响服务启动和功能。
## 当前代码基准与注意事项 ## 当前代码基准与注意事项
@@ -53,7 +53,7 @@ export class CertificateService {
} }
async update(id: number, dto: UpdateCertificateDto) { async update(id: number, dto: UpdateCertificateDto) {
const cert = await this.ensureCert(id); await this.ensureCert(id);
const updated = await this.prisma.certificate.update({ const updated = await this.prisma.certificate.update({
where: { id }, where: { id },
data: { data: {
@@ -25,9 +25,7 @@ import { OutboundDto } from './dto/outbound.dto';
import { QueryImportRowsDto } from './dto/import-session.dto'; import { QueryImportRowsDto } from './dto/import-session.dto';
const ZIP_MAX_SIZE = 30 * 1024 * 1024; const ZIP_MAX_SIZE = 30 * 1024 * 1024;
const IMAGE_MAX_SIZE = 10 * 1024 * 1024;
const SESSION_TTL_DAYS = 2; const SESSION_TTL_DAYS = 2;
const ALLOWED_IMAGE_EXT = new Set(['.jpg', '.jpeg', '.png', '.webp']);
@Injectable() @Injectable()
export class OutboundService { export class OutboundService {
+13 -13
View File
@@ -8,7 +8,7 @@ import * as ExcelJS from 'exceljs';
import * as QRCode from 'qrcode'; import * as QRCode from 'qrcode';
import AdmZip from 'adm-zip'; import AdmZip from 'adm-zip';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ArtworkStatus, BatchStatus, ErrorCode, JobType, QUEUE_NAMES, TraceCodeStatus } from '@artveris/shared'; import { BatchStatus, ErrorCode, JobType, QUEUE_NAMES, TraceCodeStatus } from '@artveris/shared';
import { PrismaService } from '../prisma/prisma.service'; import { PrismaService } from '../prisma/prisma.service';
import { StorageService } from '../storage/storage.service'; import { StorageService } from '../storage/storage.service';
import { BusinessException } from '../common/exceptions/business.exception'; import { BusinessException } from '../common/exceptions/business.exception';
@@ -63,7 +63,7 @@ export class TraceCodeService {
const artwork = await this.prisma.artwork.findFirst({ const artwork = await this.prisma.artwork.findFirst({
where: { id: dto.artworkId, deletedAt: null }, where: { id: dto.artworkId, deletedAt: null },
}); });
if (!artwork) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '鑹烘湳鍝佷笉瀛樺湪', 404); if (!artwork) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '艺术品不存在', 404);
if (dto.groupId !== undefined && dto.groupId !== null) await this.ensureGroup(dto.groupId); if (dto.groupId !== undefined && dto.groupId !== null) await this.ensureGroup(dto.groupId);
@@ -90,7 +90,7 @@ export class TraceCodeService {
return { batchId: batch.id, batchNo, jobId: job.id, quantity: dto.quantity }; return { batchId: batch.id, batchNo, jobId: job.id, quantity: dto.quantity };
} }
// ===== 鍒嗙粍绠$悊 ===== // ===== 分组管理 =====
listGroups(artworkId?: number) { listGroups(artworkId?: number) {
return this.prisma.traceCodeGroup.findMany({ return this.prisma.traceCodeGroup.findMany({
where: artworkId ? { traceCodes: { some: { artworkId } } } : undefined, where: artworkId ? { traceCodes: { some: { artworkId } } } : undefined,
@@ -121,7 +121,7 @@ export class TraceCodeService {
return g; return g;
} }
// ===== 鎵归噺鎿嶄綔 ===== // ===== 批量操作 =====
async batchSetGroup(dto: BatchGroupDto) { async batchSetGroup(dto: BatchGroupDto) {
const ids = dto.ids.map((i) => BigInt(i)); const ids = dto.ids.map((i) => BigInt(i));
await this.prisma.traceCode.updateMany({ await this.prisma.traceCode.updateMany({
@@ -134,7 +134,7 @@ export class TraceCodeService {
async batchSetStatus(dto: BatchStatusDto) { async batchSetStatus(dto: BatchStatusDto) {
const ids = dto.ids.map((i) => BigInt(i)); const ids = dto.ids.map((i) => BigInt(i));
if (dto.abnormal) { if (dto.abnormal) {
// 鏍囪寮傚父锛氱敤浜庤繍钀ヤ汉涓烘爣娉ㄧ枒浼艰澶嶅埗/鐩楃敤鐨勭爜 // 标记异常:用于运营人员标注疑似被复制/盗用的码
await this.prisma.traceCode.updateMany({ await this.prisma.traceCode.updateMany({
where: { id: { in: ids } }, where: { id: { in: ids } },
data: { status: TraceCodeStatus.ABNORMAL }, data: { status: TraceCodeStatus.ABNORMAL },
@@ -145,7 +145,7 @@ export class TraceCodeService {
data: { status: TraceCodeStatus.DISABLED }, data: { status: TraceCodeStatus.DISABLED },
}); });
} else { } else {
// 鍚敤锛氬凡婵€娲昏繃鐨勬仮澶嶄负 ACTIVE锛屽惁鍒欐仮澶嶄负 INACTIVE // 启用:已激活过的恢复为 ACTIVE,否则恢复为 INACTIVE
await this.prisma.$transaction([ await this.prisma.$transaction([
this.prisma.traceCode.updateMany({ this.prisma.traceCode.updateMany({
where: { id: { in: ids }, firstActivatedAt: { not: null } }, where: { id: { in: ids }, firstActivatedAt: { not: null } },
@@ -184,12 +184,12 @@ export class TraceCodeService {
} }
if (!options.batchId) { if (!options.batchId) {
throw new BusinessException(ErrorCode.BAD_REQUEST, '璇烽€夋嫨鐩爣鎵规鎴栧~鍐欐柊鎵规缂栧彿'); throw new BusinessException(ErrorCode.BAD_REQUEST, '请选择目标批次或填写新批次编号');
} }
const targetBatch = await this.prisma.batch.findUnique({ where: { id: options.batchId } }); const targetBatch = await this.prisma.batch.findUnique({ where: { id: options.batchId } });
if (!targetBatch || targetBatch.artworkId !== options.artworkId) { if (!targetBatch || targetBatch.artworkId !== options.artworkId) {
throw new BusinessException(ErrorCode.BAD_REQUEST, '鐩爣鎵规涓嶅瓨鍦ㄦ垨涓嶅睘浜庡綋鍓嶈壓鏈搧妗f'); throw new BusinessException(ErrorCode.BAD_REQUEST, '目标批次不存在或不属于当前艺术品档案');
} }
return targetBatch; return targetBatch;
} }
@@ -213,11 +213,11 @@ export class TraceCodeService {
select: { id: true, artworkId: true, batchId: true }, select: { id: true, artworkId: true, batchId: true },
}); });
if (codes.length !== ids.length) { if (codes.length !== ids.length) {
throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '閮ㄥ垎杩芥函鐮佷笉瀛樺湪', 404); throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '部分追溯码不存在', 404);
} }
const artworkIds = new Set(codes.map((c) => c.artworkId)); const artworkIds = new Set(codes.map((c) => c.artworkId));
if (artworkIds.size !== 1) { if (artworkIds.size !== 1) {
throw new BusinessException(ErrorCode.BAD_REQUEST, '鍙兘鎵归噺绉诲姩鍚屼竴鑹烘湳鍝佹。妗堜笅鐨勮拷婧爜'); throw new BusinessException(ErrorCode.BAD_REQUEST, '只能批量移动同一艺术品档案下的追溯码');
} }
const artworkId = codes[0].artworkId; const artworkId = codes[0].artworkId;
@@ -263,7 +263,7 @@ export class TraceCodeService {
async updateOne(id: string, dto: UpdateTraceCodeDto, userId?: number) { async updateOne(id: string, dto: UpdateTraceCodeDto, userId?: number) {
const traceCodeId = BigInt(id); const traceCodeId = BigInt(id);
const code = await this.prisma.traceCode.findUnique({ where: { id: traceCodeId } }); const code = await this.prisma.traceCode.findUnique({ where: { id: traceCodeId } });
if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '杩芥函鐮佷笉瀛樺湪', 404); if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '追溯码不存在', 404);
const data: Prisma.TraceCodeUncheckedUpdateInput = {}; const data: Prisma.TraceCodeUncheckedUpdateInput = {};
let targetBatchId: number | undefined; let targetBatchId: number | undefined;
@@ -339,7 +339,7 @@ export class TraceCodeService {
select: { id: true, batchId: true }, select: { id: true, batchId: true },
}); });
if (codes.length !== ids.length) { if (codes.length !== ids.length) {
throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '閮ㄥ垎杩芥函鐮佷笉瀛樺湪', 404); throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '部分追溯码不存在', 404);
} }
const batchCounts = new Map<number, number>(); const batchCounts = new Map<number, number>();
for (const code of codes) { for (const code of codes) {
@@ -452,7 +452,7 @@ export class TraceCodeService {
async getQrPng(id: bigint): Promise<Buffer> { async getQrPng(id: bigint): Promise<Buffer> {
const code = await this.prisma.traceCode.findUnique({ where: { id } }); const code = await this.prisma.traceCode.findUnique({ where: { id } });
if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '杩芥函鐮佷笉瀛樺湪', 404); if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '追溯码不存在', 404);
return QRCode.toBuffer(code.url || this.buildTraceUrl(code.shortCode), { return QRCode.toBuffer(code.url || this.buildTraceUrl(code.shortCode), {
type: 'png', type: 'png',
width: 320, width: 320,
+1 -2
View File
@@ -29,8 +29,7 @@
"esbuild", "esbuild",
"@scarf/scarf", "@scarf/scarf",
"msgpackr-extract", "msgpackr-extract",
"vue-demi", "vue-demi"
"esbuild"
] ]
} }
} }