diff --git a/src/utils/index.ts b/src/utils/index.ts index 8ff2d97..792cd07 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -67,6 +67,20 @@ export default class Utils { } else return ""; } + /** + * 在线预览大小上限(字节):日志大字段(请求体/响应)超过此值时隐藏"在线预览"、只保留"下载"。 + * 浏览器 JSON 美化 +
渲染在数百 KB 起会卡顿,50KB 为体验无损的保守阈值。
+ */
+ public static readonly PREVIEW_MAX_BYTES = 50 * 1024;
+
+ /**
+ * 是否允许在线预览:有内容(size > 0)且字节数不超过阈值。
+ * size 为 null/undefined/0(未记录请求体、saveResponse=false、响应为空)→ 不可预览,仅下载。
+ */
+ public static canPreview(size?: number | null): boolean {
+ return size != null && size > 0 && size <= Utils.PREVIEW_MAX_BYTES;
+ }
+
/**
* 删除指定键
*/
diff --git a/src/views/oapilog/OapiLogDetailModal.vue b/src/views/oapilog/OapiLogDetailModal.vue
index d3c0f79..a032925 100644
--- a/src/views/oapilog/OapiLogDetailModal.vue
+++ b/src/views/oapilog/OapiLogDetailModal.vue
@@ -20,7 +20,13 @@
{{ formatJson(row?.requestParams) }}
- {{ formatJson(row?.responseData) }}
+
+ 下载
+ 在线预览
+ ({{ sizeText }})
+
+ -
{{ formatTime(row?.createTime) }}
@@ -31,10 +37,18 @@
+
+
+ {{ previewText }}
+
+
+
+
diff --git a/src/views/oapilog/OapiLogList.vue b/src/views/oapilog/OapiLogList.vue
index ef070d3..891368d 100644
--- a/src/views/oapilog/OapiLogList.vue
+++ b/src/views/oapilog/OapiLogList.vue
@@ -151,6 +151,13 @@ const columns = [
align: 'right',
render: (h: any, { row }: any) => h('span', row.costTime != null ? `${row.costTime} ms` : '-'),
},
+ {
+ title: '响应',
+ key: 'responseSize',
+ width: 90,
+ align: 'right',
+ render: (h: any, { row }: any) => h('span', row.responseSize != null && row.responseSize > 0 ? Utils.getFileSize(row.responseSize) : '-'),
+ },
{
title: '调用时间',
key: 'createTime',
diff --git a/src/views/oplog/OperationLogDetailModal.vue b/src/views/oplog/OperationLogDetailModal.vue
index bb271d7..fe08de8 100644
--- a/src/views/oplog/OperationLogDetailModal.vue
+++ b/src/views/oplog/OperationLogDetailModal.vue
@@ -20,7 +20,12 @@
{{ formatJson(row?.requestParams) }}
- 下载
+
+ 下载
+ 在线预览
+ ({{ sizeText }})
+
-
@@ -32,10 +37,17 @@
+
+
+ {{ previewText }}
+
+
+
+
diff --git a/src/views/oplog/OperationLogList.vue b/src/views/oplog/OperationLogList.vue
index f249afb..4c542ee 100644
--- a/src/views/oplog/OperationLogList.vue
+++ b/src/views/oplog/OperationLogList.vue
@@ -152,6 +152,13 @@ const columns = [
align: 'right',
render: (h: any, { row }: any) => h('span', row.costTime != null ? `${row.costTime} ms` : '-'),
},
+ {
+ title: '响应',
+ key: 'responseSize',
+ width: 90,
+ align: 'right',
+ render: (h: any, { row }: any) => h('span', row.responseSize != null && row.responseSize > 0 ? Utils.getFileSize(row.responseSize) : '-'),
+ },
{
title: '操作时间ed',
key: 'createTime',
diff --git a/src/views/push/PushLog.vue b/src/views/push/PushLog.vue
index 6f88ae1..d3f72e3 100644
--- a/src/views/push/PushLog.vue
+++ b/src/views/push/PushLog.vue
@@ -156,6 +156,13 @@ const columns = [
align: 'right',
render: (h: any, { row }: any) => h('span', row.costMs != null ? `${row.costMs}` : '-'),
},
+ {
+ title: '请求体',
+ key: 'payloadSize',
+ width: 100,
+ align: 'right',
+ render: (h: any, { row }: any) => h('span', row.payloadSize != null && row.payloadSize > 0 ? Utils.getFileSize(row.payloadSize) : '-'),
+ },
{
title: '操作',
key: 'action',
diff --git a/src/views/push/PushLogDetailModal.vue b/src/views/push/PushLogDetailModal.vue
index 3bfa0a5..0824c1f 100644
--- a/src/views/push/PushLogDetailModal.vue
+++ b/src/views/push/PushLogDetailModal.vue
@@ -43,7 +43,12 @@
{{ formatTime(row?.createdAt) }}
- 下载请求体
+
+ 下载请求体
+ 在线预览
+ ({{ sizeText }})
+
-
@@ -51,10 +56,17 @@
+
+
+ {{ previewText }}
+
+
+
+