fix(oper-log): fix json.parse error
This commit is contained in:
@@ -45,15 +45,15 @@ const OperLog: React.FC = () => {
|
||||
return `'${item.operName || '-'}' Logout`;
|
||||
},
|
||||
'data-source insert': (item) => {
|
||||
const operParam = JSON.parse(item.operParam || '{}');
|
||||
const operParam = parseOperParam(item);
|
||||
return `Add Data Source: '${operParam.sourceName || '-'}'`;
|
||||
},
|
||||
'rule insert': (item) => {
|
||||
const operParam = JSON.parse(item.operParam || '{}');
|
||||
const operParam = parseOperParam(item);
|
||||
return `Add Rule: '${ruleBaseMeta[operParam.type].title || '-'}'`;
|
||||
},
|
||||
'rule update': (item) => {
|
||||
const operParam = JSON.parse(item.operParam || '{}');
|
||||
const operParam = parseOperParam(item);
|
||||
return `Update Rule: '${ruleBaseMeta[operParam.type].title || '-'}'`;
|
||||
},
|
||||
'rule update status': (item) => {
|
||||
@@ -63,6 +63,15 @@ const OperLog: React.FC = () => {
|
||||
},
|
||||
};
|
||||
|
||||
function parseOperParam(item: API.OperLogListItem) {
|
||||
try {
|
||||
return JSON.parse(item.operParam || '{}');
|
||||
} catch (error) {
|
||||
console.error('parse operParam error', error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const columns: ProColumns<API.OperLogListItem>[] = [
|
||||
{
|
||||
title: $t('table.time'),
|
||||
|
||||
Reference in New Issue
Block a user