fix: 修复系统图标与操作日志映射
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user