feat: ele use desc comp
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraApiAccessLogApi } from '#/api/infra/api-access-log';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
@@ -181,10 +180,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'userType',
|
||||
label: '用户类型',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.USER_TYPE,
|
||||
value: data.userType,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -198,9 +197,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
},
|
||||
{
|
||||
label: '请求信息',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
field: 'requestMethod',
|
||||
render: (val, data) => {
|
||||
if (data?.requestMethod && data?.requestUrl) {
|
||||
return `${data.requestMethod} ${data.requestUrl}`;
|
||||
return `${val} ${data.requestUrl}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -208,10 +208,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'requestParams',
|
||||
label: '请求参数',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
if (data.requestParams) {
|
||||
render: (val) => {
|
||||
if (val) {
|
||||
return h(JsonViewer, {
|
||||
value: JSON.parse(data.requestParams),
|
||||
value: JSON.parse(val),
|
||||
previewMode: true,
|
||||
});
|
||||
}
|
||||
@@ -224,26 +224,29 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
},
|
||||
{
|
||||
label: '请求时间',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
field: 'beginTime',
|
||||
render: (val, data) => {
|
||||
if (data?.beginTime && data?.endTime) {
|
||||
return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`;
|
||||
return `${formatDateTime(val)} ~ ${formatDateTime(data.endTime)}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '请求耗时',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
return data?.duration ? `${data.duration} ms` : '';
|
||||
field: 'duration',
|
||||
render: (val) => {
|
||||
return val ? `${val} ms` : '';
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '操作结果',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
if (data?.resultCode === 0) {
|
||||
field: 'resultCode',
|
||||
render: (val, data) => {
|
||||
if (val === 0) {
|
||||
return '正常';
|
||||
} else if (data && data.resultCode > 0) {
|
||||
return `失败 | ${data.resultCode} | ${data.resultMsg}`;
|
||||
return `失败 | ${val} | ${data.resultMsg}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -259,10 +262,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'operateType',
|
||||
label: '操作类型',
|
||||
content: (data: InfraApiAccessLogApi.ApiAccessLog) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_OPERATE_TYPE,
|
||||
value: data?.operateType,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
|
||||
const formData = ref<InfraApiAccessLogApi.ApiAccessLog>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
},
|
||||
column: 1,
|
||||
labelWidth: 110,
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
@@ -158,10 +157,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'userType',
|
||||
label: '用户类型',
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.USER_TYPE,
|
||||
value: data.userType,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -176,9 +175,9 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'requestMethod',
|
||||
label: '请求信息',
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
render: (val, data) => {
|
||||
if (data?.requestMethod && data?.requestUrl) {
|
||||
return `${data.requestMethod} ${data.requestUrl}`;
|
||||
return `${val} ${data.requestUrl}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -186,10 +185,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'requestParams',
|
||||
label: '请求参数',
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
if (data.requestParams) {
|
||||
render: (val) => {
|
||||
if (val) {
|
||||
return h(JsonViewer, {
|
||||
value: JSON.parse(data.requestParams),
|
||||
value: JSON.parse(val),
|
||||
previewMode: true,
|
||||
});
|
||||
}
|
||||
@@ -199,9 +198,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'exceptionTime',
|
||||
label: '异常时间',
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
return formatDateTime(data?.exceptionTime || '') as string;
|
||||
},
|
||||
render: (val) => formatDateTime(val) as string,
|
||||
},
|
||||
{
|
||||
field: 'exceptionName',
|
||||
@@ -210,12 +207,11 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'exceptionStackTrace',
|
||||
label: '异常堆栈',
|
||||
hidden: (data: InfraApiErrorLogApi.ApiErrorLog) =>
|
||||
!data?.exceptionStackTrace,
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
if (data?.exceptionStackTrace) {
|
||||
show: (val) => !val,
|
||||
render: (val) => {
|
||||
if (val) {
|
||||
return h('textarea', {
|
||||
value: data.exceptionStackTrace,
|
||||
value: val,
|
||||
style:
|
||||
'width: 100%; min-height: 200px; max-height: 400px; resize: vertical;',
|
||||
readonly: true,
|
||||
@@ -227,25 +223,23 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'processStatus',
|
||||
label: '处理状态',
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS,
|
||||
value: data?.processStatus,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'processUserId',
|
||||
label: '处理人',
|
||||
hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processUserId,
|
||||
show: (val) => !val,
|
||||
},
|
||||
{
|
||||
field: 'processTime',
|
||||
label: '处理时间',
|
||||
hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processTime,
|
||||
content: (data: InfraApiErrorLogApi.ApiErrorLog) => {
|
||||
return formatDateTime(data?.processTime || '') as string;
|
||||
},
|
||||
show: (val) => !val,
|
||||
render: (val) => formatDateTime(val) as string,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
|
||||
const formData = ref<InfraApiErrorLogApi.ApiErrorLog>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
},
|
||||
column: 1,
|
||||
labelWidth: 110,
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraJobApi } from '#/api/infra/job';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
@@ -197,10 +196,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'status',
|
||||
label: '任务状态',
|
||||
content: (data: InfraJobApi.Job) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_JOB_STATUS,
|
||||
value: data?.status,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
@@ -222,27 +221,23 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
},
|
||||
{
|
||||
label: '重试间隔',
|
||||
content: (data: InfraJobApi.Job) => {
|
||||
return data?.retryInterval ? `${data.retryInterval} 毫秒` : '无间隔';
|
||||
},
|
||||
field: 'retryInterval',
|
||||
render: (val) => (val ? `${val} 毫秒` : '无间隔'),
|
||||
},
|
||||
{
|
||||
label: '监控超时时间',
|
||||
content: (data: InfraJobApi.Job) => {
|
||||
return data?.monitorTimeout && data.monitorTimeout > 0
|
||||
? `${data.monitorTimeout} 毫秒`
|
||||
: '未开启';
|
||||
},
|
||||
field: 'monitorTimeout',
|
||||
render: (val) => (val && val > 0 ? `${val} 毫秒` : '未开启'),
|
||||
},
|
||||
{
|
||||
field: 'nextTimes',
|
||||
label: '后续执行时间',
|
||||
content: (data: InfraJobApi.Job) => {
|
||||
if (!data?.nextTimes || data.nextTimes.length === 0) {
|
||||
render: (val) => {
|
||||
if (!val || val.length === 0) {
|
||||
return '无后续执行时间';
|
||||
}
|
||||
return h(ElTimeline, {}, () =>
|
||||
data.nextTimes?.map((time: Date) =>
|
||||
val?.map((time: Date) =>
|
||||
h(ElTimelineItem, {}, () => formatDateTime(time)),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraJobLogApi } from '#/api/infra/job-log';
|
||||
import type { DescriptionItemSchema } from '#/components/description';
|
||||
|
||||
import { h } from 'vue';
|
||||
@@ -154,9 +153,9 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'beginTime',
|
||||
label: '执行时间',
|
||||
content: (data: InfraJobLogApi.JobLog) => {
|
||||
if (data?.beginTime && data?.endTime) {
|
||||
return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`;
|
||||
render: (val, data) => {
|
||||
if (val && data?.endTime) {
|
||||
return `${formatDateTime(val)} ~ ${formatDateTime(data.endTime)}`;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -164,17 +163,15 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'duration',
|
||||
label: '执行时长',
|
||||
content: (data: InfraJobLogApi.JobLog) => {
|
||||
return data?.duration ? `${data.duration} 毫秒` : '';
|
||||
},
|
||||
render: (val) => (val ? `${val} 毫秒` : ''),
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
label: '任务状态',
|
||||
content: (data: InfraJobLogApi.JobLog) => {
|
||||
render: (val) => {
|
||||
return h(DictTag, {
|
||||
type: DICT_TYPE.INFRA_JOB_LOG_STATUS,
|
||||
value: data?.status,
|
||||
value: val,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -13,14 +13,8 @@ import { useDetailSchema } from '../data';
|
||||
const formData = ref<InfraJobLogApi.JobLog>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
},
|
||||
column: 1,
|
||||
labelWidth: 140,
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
|
||||
@@ -14,14 +14,8 @@ const formData = ref<InfraJobApi.Job>(); // 任务详情
|
||||
const nextTimes = ref<Date[]>([]); // 下一次执行时间
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
componentProps: {
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
},
|
||||
column: 1,
|
||||
labelWidth: 140,
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,55 +1,73 @@
|
||||
<script lang="ts" setup>
|
||||
import type { InfraRedisApi } from '#/api/infra/redis';
|
||||
|
||||
import { ElDescriptions, ElDescriptionsItem } from 'element-plus';
|
||||
import { useDescription } from '#/components/description';
|
||||
|
||||
defineProps<{
|
||||
redisData?: InfraRedisApi.RedisMonitorInfo;
|
||||
}>();
|
||||
|
||||
const [Descriptions] = useDescription({
|
||||
bordered: false,
|
||||
column: 6,
|
||||
schema: [
|
||||
{
|
||||
field: 'info.redis_version',
|
||||
label: 'Redis 版本',
|
||||
},
|
||||
{
|
||||
field: 'info.redis_mode',
|
||||
label: '运行模式',
|
||||
render: (val) => (val === 'standalone' ? '单机' : '集群'),
|
||||
},
|
||||
{
|
||||
field: 'info.tcp_port',
|
||||
label: '端口',
|
||||
},
|
||||
{
|
||||
field: 'info.connected_clients',
|
||||
label: '客户端数',
|
||||
},
|
||||
{
|
||||
field: 'info.uptime_in_days',
|
||||
label: '运行时间(天)',
|
||||
},
|
||||
{
|
||||
field: 'info.used_memory_human',
|
||||
label: '使用内存',
|
||||
},
|
||||
{
|
||||
field: 'info.used_cpu_user_children',
|
||||
label: '使用 CPU',
|
||||
render: (val) => Number.parseFloat(val).toFixed(2),
|
||||
},
|
||||
{
|
||||
field: 'info.maxmemory_human',
|
||||
label: '内存配置',
|
||||
},
|
||||
{
|
||||
field: 'info.aof_enabled',
|
||||
label: 'AOF 是否开启',
|
||||
render: (val) => (val === '0' ? '否' : '是'),
|
||||
},
|
||||
{
|
||||
field: 'info.rdb_last_bgsave_status',
|
||||
label: 'RDB 是否成功',
|
||||
},
|
||||
{
|
||||
field: 'dbSize',
|
||||
label: 'Key 数量',
|
||||
},
|
||||
{
|
||||
field: 'info.instantaneous_input_kbps',
|
||||
label: '网络入口/出口',
|
||||
render: (val, data) =>
|
||||
`${val}kps / ${data?.info?.instantaneous_output_kbps}kps`,
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDescriptions :column="6" border size="default" :label-width="138">
|
||||
<ElDescriptionsItem label="Redis 版本">
|
||||
{{ redisData?.info?.redis_version }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="运行模式">
|
||||
{{ redisData?.info?.redis_mode === 'standalone' ? '单机' : '集群' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="端口">
|
||||
{{ redisData?.info?.tcp_port }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="客户端数">
|
||||
{{ redisData?.info?.connected_clients }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="运行时间(天)">
|
||||
{{ redisData?.info?.uptime_in_days }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="使用内存">
|
||||
{{ redisData?.info?.used_memory_human }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="使用 CPU">
|
||||
{{
|
||||
redisData?.info
|
||||
? parseFloat(redisData?.info?.used_cpu_user_children).toFixed(2)
|
||||
: ''
|
||||
}}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="内存配置">
|
||||
{{ redisData?.info?.maxmemory_human }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="AOF 是否开启">
|
||||
{{ redisData?.info?.aof_enabled === '0' ? '否' : '是' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="RDB 是否成功">
|
||||
{{ redisData?.info?.rdb_last_bgsave_status }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="Key 数量">
|
||||
{{ redisData?.dbSize }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="网络入口/出口">
|
||||
{{ redisData?.info?.instantaneous_input_kbps }}kps /
|
||||
{{ redisData?.info?.instantaneous_output_kbps }}kps
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
<Descriptions :data="redisData" />
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user