From cd16c1322d5b62bc402ea2fa67bc1fcc4a6497c4 Mon Sep 17 00:00:00 2001 From: wuwen Date: Mon, 16 Jan 2023 18:45:08 +0800 Subject: [PATCH] fix: Formatted display of json content type(Compatible with illegal json) --- .../dashboard/related/log/LogTable/LogDetail.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/views/dashboard/related/log/LogTable/LogDetail.vue b/src/views/dashboard/related/log/LogTable/LogDetail.vue index e65d8954..6d4cc704 100644 --- a/src/views/dashboard/related/log/LogTable/LogDetail.vue +++ b/src/views/dashboard/related/log/LogTable/LogDetail.vue @@ -23,9 +23,7 @@ limitations under the License. --> class="content mb-10" :readonly="true" v-else-if="item.label === 'content'" - :value=" - currentLog.contentType === 'JSON' ? formatJson(JSON.parse(currentLog[item.label])) : currentLog[item.label] - " + :value="contentFormat(item.label)" />
{{ d }}
@@ -56,6 +54,16 @@ limitations under the License. --> return `${d.key} = ${d.value}`; }); }); + + function contentFormat(label: string) { + try { + return props.currentLog.contentType === "JSON" + ? formatJson(JSON.parse(props.currentLog[label])) + : props.currentLog[label]; + } catch (e) { + return props.currentLog[label]; + } + }