fix: 修复系统图标与操作日志映射
This commit is contained in:
@@ -209,3 +209,4 @@
|
||||
- 存储/CDN 设置与迁移接口(2026-07-06):系统设置新增 `clientBaseUrl`、存储方式、本地目录、CDN、OSS/S3 配置;OSS Secret 返回时脱敏。新增 `/api/storage/test`、`/api/storage/migrate`、`/api/storage/confirm`:可测试目标存储、把当前存储文件复制到目标存储、确认切换设置。第一版迁移按存储 key 复制业务文件,配置变更仍需重启后完整服务使用新驱动。
|
||||
- i18n 响应结构(2026-07-06):共享 `ApiResponse` 扩展 `messageKey`/`params`,后端 `BusinessException` 和全局异常过滤器返回稳定 `error.*` key,前端请求统一带 `Accept-Language`,后台错误提示优先按 `messageKey` 翻译、再按错误码兜底。后台 locales 已补 `error.*` 中英文别名,避免英文模式直接显示中文后端消息。
|
||||
- 发布包与存储迁移收口(2026-07-06):非 Docker 发布包新增 `install-deps.sh` / `install-deps.ps1`,标准安装流程为 `pnpm install --prod --frozen-lockfile` 后在 `apps/api` 目录执行 `prisma generate --schema ./prisma/schema.prisma`,避免生产包启动时报缺 `.prisma/client/default`。发布包只复制 shared 的 `dist` 与 `package.json`,不再带源码和局部 node_modules。存储迁移状态只保存脱敏目标配置和 `storageMigrationFingerprint`,确认切换前必须匹配同目标迁移记录;OSS/Tianhe Secret 继续 AES-GCM 加密保存,接口返回脱敏,备份使用 raw 设置值。最终验证过发布包安装脚本、安装模式 `/api/install/status` 200、未安装 `/admin` 404、单端口监听正常。
|
||||
- 子路径默认图标与操作日志映射修复(2026-07-07):单端口路径部署下默认图标必须使用前后台各自子路径,后台默认 `/admin/app-icon.svg`,客户端默认 `/trace/app-icon.svg`;后端 `appIconUrl` 默认保持空值,由前端按所在端回退默认图标,并兼容历史设置值 `/app-icon.svg` 为空,避免设置页、登录页、侧边栏和 favicon 断图。操作日志后端不再用粗略 `path.includes('/backup')` 判定动作,改为按路径段明确识别备份创建/删除/下载/恢复预检/恢复确认、批量删除追溯码、出库导入、存储迁移、修改密码、区块链确认/重试等动作;新增单测覆盖备份删除不再显示为创建备份。后台操作日志页会按 `method + path` 推导有效动作和摘要,兼容已写入错误 `action=backup` 的历史删除备份日志,并补齐存储、证书、溯源节点、区块链存证等模块和路径摘要的中英文 i18n。已验证 API 单测、API/admin/client 构建和浏览器烟测:默认图标无断图,历史删除备份日志在“操作/操作摘要”均显示为删除。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/app-icon.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/admin/app-icon.svg" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -518,6 +518,10 @@
|
||||
"backups": "Backup & Restore",
|
||||
"settings": "Settings",
|
||||
"users": "Users",
|
||||
"storage": "Storage & CDN",
|
||||
"certificates": "Certificates",
|
||||
"nodes": "Trace Nodes",
|
||||
"blockchainProofs": "Blockchain Proofs",
|
||||
"upload": "Upload",
|
||||
"download": "Download",
|
||||
"export": "Export"
|
||||
@@ -530,9 +534,23 @@
|
||||
"paths": {
|
||||
"outboundPreview": "Outbound import preview",
|
||||
"outboundCommit": "Confirm outbound import",
|
||||
"outboundTemplate": "Download outbound import template",
|
||||
"traceExport": "Export trace codes and QR images",
|
||||
"traceBatchDelete": "Batch delete trace codes",
|
||||
"traceOnchain": "Trace code on-chain attestation",
|
||||
"backupCreate": "Create backup",
|
||||
"backupDelete": "Delete backup",
|
||||
"backupDownload": "Download backup package",
|
||||
"backupRestorePreview": "Upload backup package for pre-check",
|
||||
"backup": "Backup management",
|
||||
"restore": "Restore backup",
|
||||
"storageTest": "Test storage config",
|
||||
"storageMigrate": "Migrate storage files",
|
||||
"storageConfirm": "Switch storage config",
|
||||
"blockchainRetry": "Retry blockchain proof",
|
||||
"blockchainConfirm": "Query blockchain confirmation",
|
||||
"changePassword": "Change password",
|
||||
"login": "Sign in to admin",
|
||||
"upload": "Upload file"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -518,6 +518,10 @@
|
||||
"backups": "备份恢复",
|
||||
"settings": "系统设置",
|
||||
"users": "用户管理",
|
||||
"storage": "存储与 CDN",
|
||||
"certificates": "认证文件",
|
||||
"nodes": "溯源节点",
|
||||
"blockchainProofs": "区块链存证",
|
||||
"upload": "文件上传",
|
||||
"download": "文件下载",
|
||||
"export": "数据导出"
|
||||
@@ -530,9 +534,23 @@
|
||||
"paths": {
|
||||
"outboundPreview": "出库批量导入预览",
|
||||
"outboundCommit": "确认出库批量导入",
|
||||
"outboundTemplate": "下载出库导入模板",
|
||||
"traceExport": "导出追溯码与二维码",
|
||||
"traceBatchDelete": "批量删除追溯码",
|
||||
"traceOnchain": "追溯码上链存证",
|
||||
"backupCreate": "创建备份",
|
||||
"backupDelete": "删除备份",
|
||||
"backupDownload": "下载备份包",
|
||||
"backupRestorePreview": "上传备份包预校验",
|
||||
"backup": "备份管理",
|
||||
"restore": "恢复备份",
|
||||
"storageTest": "测试存储配置",
|
||||
"storageMigrate": "迁移存储文件",
|
||||
"storageConfirm": "切换存储配置",
|
||||
"blockchainRetry": "重试区块链存证",
|
||||
"blockchainConfirm": "查询区块链确认结果",
|
||||
"changePassword": "修改密码",
|
||||
"login": "登录后台",
|
||||
"upload": "上传文件"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const DEFAULT_APP_ICON_URL = '/app-icon.svg';
|
||||
export const DEFAULT_APP_ICON_URL = '/admin/app-icon.svg';
|
||||
|
||||
export function resolveAppIcon(url?: string | null): string {
|
||||
const value = String(url || '').trim();
|
||||
|
||||
@@ -76,6 +76,10 @@ const moduleOptions = [
|
||||
'backups',
|
||||
'settings',
|
||||
'users',
|
||||
'storage',
|
||||
'certificates',
|
||||
'nodes',
|
||||
'blockchain-proofs',
|
||||
'upload',
|
||||
'download',
|
||||
'export',
|
||||
@@ -112,7 +116,7 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
width: 120,
|
||||
align: 'center',
|
||||
ellipsis: { tooltip: true },
|
||||
render: (row) => actionLabel(row.action),
|
||||
render: (row) => actionLabel(effectiveAction(row)),
|
||||
},
|
||||
{
|
||||
title: () => renderTableFilterTitle(t('pages.operationLog.result'), query.status, resultOptions, (value) => setFilter('status', value)),
|
||||
@@ -149,6 +153,10 @@ function moduleLabel(value?: string) {
|
||||
backups: t('pages.operationLog.modules.backups'),
|
||||
settings: t('pages.operationLog.modules.settings'),
|
||||
users: t('pages.operationLog.modules.users'),
|
||||
storage: t('pages.operationLog.modules.storage'),
|
||||
certificates: t('pages.operationLog.modules.certificates'),
|
||||
nodes: t('pages.operationLog.modules.nodes'),
|
||||
'blockchain-proofs': t('pages.operationLog.modules.blockchainProofs'),
|
||||
upload: t('pages.operationLog.modules.upload'),
|
||||
download: t('pages.operationLog.modules.download'),
|
||||
export: t('pages.operationLog.modules.export'),
|
||||
@@ -177,22 +185,62 @@ function roleLabel(value?: string) {
|
||||
return value ? t(`common.role.${value}`) : '-';
|
||||
}
|
||||
|
||||
function pathLabel(path?: string) {
|
||||
function effectiveAction(row: any) {
|
||||
const path = String(row.path || '');
|
||||
const method = String(row.method || '').toUpperCase();
|
||||
const cleanPath = path.split('?')[0];
|
||||
const isBackupRoot = /\/backups\/?$/.test(cleanPath);
|
||||
if (path.includes('/auth/login')) return 'login';
|
||||
if (path.includes('/auth/change-password')) return 'update';
|
||||
if (path.includes('/backups/restore/preview')) return 'upload';
|
||||
if (path.includes('/backups/restore/commit')) return 'restore';
|
||||
if (path.includes('/backups') && path.includes('/download')) return 'download';
|
||||
if (path.includes('/backups') && method === 'DELETE') return 'delete';
|
||||
if (isBackupRoot && method === 'POST') return 'backup';
|
||||
if (path.includes('/trace-codes/batch/delete')) return 'delete';
|
||||
if (path.includes('/outbound/import/preview') || /\/outbound\/import\/?$/.test(cleanPath)) return 'upload';
|
||||
if (path.includes('/outbound/import-sessions') && path.includes('/commit')) return 'update';
|
||||
if (path.includes('/storage/test') || path.includes('/storage/migrate') || path.includes('/storage/confirm')) return 'update';
|
||||
if ((path.includes('/blockchain-proofs') && (path.includes('/retry') || path.includes('/confirm'))) || path.includes('/trace-codes') && path.includes('/onchain')) return 'onchain';
|
||||
if (path.includes('/export')) return 'export';
|
||||
if (path.includes('/download') || path.includes('/template')) return 'download';
|
||||
return row.action;
|
||||
}
|
||||
|
||||
function pathLabel(path?: string, action?: string, method?: string) {
|
||||
if (!path) return '';
|
||||
const normalizedMethod = String(method || '').toUpperCase();
|
||||
const cleanPath = path.split('?')[0];
|
||||
const isBackupRoot = /\/backups\/?$/.test(cleanPath);
|
||||
if (path.includes('/auth/change-password')) return t('pages.operationLog.paths.changePassword');
|
||||
if (path.includes('/auth/login')) return t('pages.operationLog.paths.login');
|
||||
if (path.includes('/outbound/import/preview')) return t('pages.operationLog.paths.outboundPreview');
|
||||
if (path.includes('/outbound/import-sessions') && path.includes('/commit')) return t('pages.operationLog.paths.outboundCommit');
|
||||
if (path.includes('/trace-codes/export')) return t('pages.operationLog.paths.traceExport');
|
||||
if (path.includes('/backups/restore')) return t('pages.operationLog.paths.restore');
|
||||
if (path.includes('/trace-codes/batch/delete')) return t('pages.operationLog.paths.traceBatchDelete');
|
||||
if (path.includes('/outbound/import/template')) return t('pages.operationLog.paths.outboundTemplate');
|
||||
if (path.includes('/backups/restore/preview')) return t('pages.operationLog.paths.backupRestorePreview');
|
||||
if (path.includes('/backups/restore/commit')) return t('pages.operationLog.paths.restore');
|
||||
if (path.includes('/backups') && path.includes('/download')) return t('pages.operationLog.paths.backupDownload');
|
||||
if (path.includes('/backups') && (normalizedMethod === 'DELETE' || action === 'delete')) return t('pages.operationLog.paths.backupDelete');
|
||||
if (isBackupRoot && (normalizedMethod === 'POST' || action === 'backup')) return t('pages.operationLog.paths.backupCreate');
|
||||
if (path.includes('/backups')) return t('pages.operationLog.paths.backup');
|
||||
if (path.includes('/storage/test')) return t('pages.operationLog.paths.storageTest');
|
||||
if (path.includes('/storage/migrate')) return t('pages.operationLog.paths.storageMigrate');
|
||||
if (path.includes('/storage/confirm')) return t('pages.operationLog.paths.storageConfirm');
|
||||
if (path.includes('/blockchain-proofs') && path.includes('/retry')) return t('pages.operationLog.paths.blockchainRetry');
|
||||
if (path.includes('/blockchain-proofs') && path.includes('/confirm')) return t('pages.operationLog.paths.blockchainConfirm');
|
||||
if (path.includes('/trace-codes') && path.includes('/onchain')) return t('pages.operationLog.paths.traceOnchain');
|
||||
if (path.includes('/upload')) return t('pages.operationLog.paths.upload');
|
||||
return '';
|
||||
}
|
||||
|
||||
function operationSummary(row: any) {
|
||||
const readablePath = pathLabel(row.path);
|
||||
const action = effectiveAction(row);
|
||||
const readablePath = pathLabel(row.path, action, row.method);
|
||||
if (readablePath) return readablePath;
|
||||
const target = row.targetId ? ` #${row.targetId}` : '';
|
||||
return `${actionLabel(row.action)}${moduleLabel(row.module)}${target}`;
|
||||
return `${actionLabel(action)}${moduleLabel(row.module)}${target}`;
|
||||
}
|
||||
|
||||
function setFilter(field: 'role' | 'module' | 'action' | 'status', value: string | number | null) {
|
||||
|
||||
@@ -26,7 +26,7 @@ async function ensureAdmin() {
|
||||
async function ensureSettings() {
|
||||
const defaults = {
|
||||
appName: process.env.APP_NAME || '艺术品溯源平台',
|
||||
appIconUrl: '/app-icon.svg',
|
||||
appIconUrl: '',
|
||||
logRetentionDays: process.env.LOG_RETENTION_DAYS || '365',
|
||||
operationLogRetentionDays: process.env.OPERATION_LOG_RETENTION_DAYS || '365',
|
||||
watermarkText: process.env.WATERMARK_TEXT || '仅供溯源核验使用',
|
||||
|
||||
@@ -68,7 +68,7 @@ async function ensureUsers(): Promise<void> {
|
||||
async function ensureSettings(): Promise<void> {
|
||||
const defaults: Record<string, string> = {
|
||||
appName: process.env.APP_NAME || '艺术品溯源平台',
|
||||
appIconUrl: '/app-icon.svg',
|
||||
appIconUrl: '',
|
||||
logRetentionDays: process.env.LOG_RETENTION_DAYS || '365',
|
||||
watermarkText,
|
||||
filingInfo: '备案信息待补充',
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { actionOf, moduleOf } from './operation-log.interceptor';
|
||||
|
||||
describe('operation log route mapping', () => {
|
||||
it('keeps backup create and delete as separate actions', () => {
|
||||
expect(moduleOf('/api/backups')).toBe('backups');
|
||||
expect(actionOf('POST', '/api/backups')).toBe('backup');
|
||||
expect(actionOf('DELETE', '/api/backups/backup_001')).toBe('delete');
|
||||
});
|
||||
|
||||
it('maps backup restore flow to upload and restore actions', () => {
|
||||
expect(actionOf('POST', '/api/backups/restore/preview')).toBe('upload');
|
||||
expect(actionOf('POST', '/api/backups/restore/commit')).toBe('restore');
|
||||
expect(actionOf('GET', '/api/backups/backup_001/download')).toBe('download');
|
||||
});
|
||||
|
||||
it('maps special business operations before generic HTTP actions', () => {
|
||||
expect(actionOf('POST', '/api/trace-codes/batch/delete')).toBe('delete');
|
||||
expect(actionOf('POST', '/api/outbound/import/preview')).toBe('upload');
|
||||
expect(actionOf('POST', '/api/outbound/import-sessions/session_001/commit')).toBe('update');
|
||||
expect(actionOf('POST', '/api/auth/change-password')).toBe('update');
|
||||
expect(actionOf('POST', '/api/blockchain-proofs/1/retry')).toBe('onchain');
|
||||
expect(actionOf('POST', '/api/blockchain-proofs/1/confirm')).toBe('onchain');
|
||||
});
|
||||
|
||||
it('uses nested resource modules for certificates and trace nodes', () => {
|
||||
expect(moduleOf('/api/artworks/1/certificates')).toBe('certificates');
|
||||
expect(moduleOf('/api/artworks/1/nodes')).toBe('nodes');
|
||||
});
|
||||
});
|
||||
@@ -25,24 +25,46 @@ function sanitize(value: unknown, depth = 0): unknown {
|
||||
return out;
|
||||
}
|
||||
|
||||
function moduleOf(path: string): string {
|
||||
const p = path.replace(/^\/api\/?/, '');
|
||||
const first = p.split('/').filter(Boolean)[0] || 'root';
|
||||
if (p.includes('/export')) return 'export';
|
||||
if (p.includes('/download')) return 'download';
|
||||
return first;
|
||||
function pathSegments(path: string): string[] {
|
||||
return path
|
||||
.split('?')[0]
|
||||
.replace(/^\/api\/?/, '')
|
||||
.split('/')
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function actionOf(method: string, path: string): string {
|
||||
if (path.includes('/login')) return 'login';
|
||||
if (path.includes('/export')) return 'export';
|
||||
if (path.includes('/download')) return 'download';
|
||||
if (path.includes('/upload')) return 'upload';
|
||||
if (path.includes('/audit')) return 'audit';
|
||||
if (path.includes('/blockchain-proofs') && path.includes('/confirm')) return 'onchain';
|
||||
if (path.includes('/onchain')) return 'onchain';
|
||||
if (path.includes('/backup')) return 'backup';
|
||||
if (path.includes('/restore')) return 'restore';
|
||||
export function moduleOf(path: string): string {
|
||||
const segments = pathSegments(path);
|
||||
if (segments.includes('certificates')) return 'certificates';
|
||||
if (segments.includes('nodes')) return 'nodes';
|
||||
return segments[0] || 'root';
|
||||
}
|
||||
|
||||
export function actionOf(method: string, path: string): string {
|
||||
const segments = pathSegments(path);
|
||||
const [resource, second, third] = segments;
|
||||
const last = segments[segments.length - 1] || '';
|
||||
|
||||
if (resource === 'auth' && segments.includes('login')) return 'login';
|
||||
if (resource === 'auth' && segments.includes('change-password')) return 'update';
|
||||
if (resource === 'backups') {
|
||||
if (method === 'POST' && segments.length === 1) return 'backup';
|
||||
if (second === 'restore' && third === 'preview') return 'upload';
|
||||
if (second === 'restore' && third === 'commit') return 'restore';
|
||||
if (last === 'download') return 'download';
|
||||
}
|
||||
if (resource === 'trace-codes' && second === 'batch' && third === 'delete') return 'delete';
|
||||
if (resource === 'outbound') {
|
||||
if (second === 'import') return 'upload';
|
||||
if (second === 'import-sessions' && last === 'commit') return 'update';
|
||||
}
|
||||
if (resource === 'storage' && ['test', 'migrate', 'confirm'].includes(second || '')) return 'update';
|
||||
if (segments.includes('export')) return 'export';
|
||||
if (segments.includes('download') || last === 'template') return 'download';
|
||||
if (segments.includes('upload')) return 'upload';
|
||||
if (segments.includes('audit')) return 'audit';
|
||||
if (resource === 'blockchain-proofs' && ['retry', 'confirm'].includes(last)) return 'onchain';
|
||||
if (segments.includes('onchain')) return 'onchain';
|
||||
if (method === 'POST') return 'create';
|
||||
if (method === 'PUT' || method === 'PATCH') return 'update';
|
||||
if (method === 'DELETE') return 'delete';
|
||||
|
||||
@@ -60,7 +60,7 @@ export class SettingsService {
|
||||
const rows = await this.prisma.systemSetting.findMany();
|
||||
const map: Record<string, string> = {
|
||||
appName: this.config.get<string>('appName') || '',
|
||||
appIconUrl: '/app-icon.svg',
|
||||
appIconUrl: '',
|
||||
logRetentionDays: String(this.config.get<number>('logRetentionDays') || 365),
|
||||
operationLogRetentionDays: '365',
|
||||
watermarkText: this.config.get<string>('watermarkText') || '仅供溯源核验使用',
|
||||
@@ -93,7 +93,7 @@ export class SettingsService {
|
||||
const value = SECRET_KEYS.has(r.key) ? await this.decryptSecret(r.value) : r.value;
|
||||
map[r.key] = r.key === 'appName' && value === '艺术品可信溯源与认证平台' ? '艺术品溯源平台' : value;
|
||||
}
|
||||
if (!map.appIconUrl) map.appIconUrl = '/app-icon.svg';
|
||||
if (map.appIconUrl === '/app-icon.svg') map.appIconUrl = '';
|
||||
if (maskSecrets) {
|
||||
if (map.ossAccessKeySecret) map.ossAccessKeySecret = this.maskSecret(map.ossAccessKeySecret);
|
||||
if (map.tianheAppKey) map.tianheAppKey = this.maskSecret(map.tianheAppKey);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="/app-icon.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/trace/app-icon.svg" />
|
||||
<title>艺术品溯源平台</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const DEFAULT_APP_ICON_URL = '/app-icon.svg';
|
||||
export const DEFAULT_APP_ICON_URL = '/trace/app-icon.svg';
|
||||
|
||||
export function resolveAppIcon(url?: string | null): string {
|
||||
const value = String(url || '').trim();
|
||||
|
||||
Reference in New Issue
Block a user