初始化询价智能体新仓:同步本地工程并排除密钥与 .env。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div class="p-4">
|
||||
<BasicTable @register="registerTable" :dataSource="dataSource">
|
||||
<template #tableTitle>
|
||||
<div slot="message">
|
||||
共追踪到 {{ dataSource.length }} 条近期HTTP请求记录
|
||||
<a-divider type="vertical" />
|
||||
<a @click="loadDate">立即刷新</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</BasicTable>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" name="monitor-trace" setup>
|
||||
import { onMounted, ref, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { getActuatorList } from './trace.api';
|
||||
import { columns } from './trace.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const dataSource = ref([]);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const [registerTable, { reload }] = useTable({
|
||||
columns,
|
||||
showIndexColumn: false,
|
||||
bordered: true,
|
||||
rowKey: 'id',
|
||||
});
|
||||
|
||||
function loadDate() {
|
||||
getActuatorList().then((res) => {
|
||||
let filterData = [];
|
||||
for (let d of res.traces) {
|
||||
if (d.request.method !== 'OPTIONS' && d.request.uri.indexOf('httptrace') === -1) {
|
||||
filterData.push(d);
|
||||
}
|
||||
}
|
||||
dataSource.value = filterData;
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadDate();
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
actuatorList = '/actuator/httptrace',
|
||||
}
|
||||
|
||||
/**
|
||||
* 追踪信息
|
||||
*/
|
||||
export const getActuatorList = () => {
|
||||
return defHttp.get({ url: Api.actuatorList }, { isTransformResponse: false });
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
import { BasicColumn } from '/@/components/Table';
|
||||
import dayjs from 'dayjs';
|
||||
import _get from 'lodash.get';
|
||||
import { h } from 'vue';
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '请求时间',
|
||||
dataIndex: 'timestamp',
|
||||
width: 50,
|
||||
customRender({ text }) {
|
||||
return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '请求方法',
|
||||
dataIndex: 'request.method',
|
||||
width: 20,
|
||||
customRender({ record, column }) {
|
||||
let value = _get(record, column.dataIndex!);
|
||||
let color = '';
|
||||
if (value === 'GET') {
|
||||
color = '#87d068';
|
||||
}
|
||||
if (value === 'POST') {
|
||||
color = '#2db7f5';
|
||||
}
|
||||
if (value === 'PUT') {
|
||||
color = '#ffba5a';
|
||||
}
|
||||
if (value === 'DELETE') {
|
||||
color = '#ff5500';
|
||||
}
|
||||
return h(Tag, { color }, () => value);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '请求URL',
|
||||
dataIndex: 'request.uri',
|
||||
width: 200,
|
||||
customRender({ record, column }) {
|
||||
return _get(record, column.dataIndex!);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '响应状态',
|
||||
dataIndex: 'response.status',
|
||||
width: 50,
|
||||
customRender({ record, column }) {
|
||||
let value = _get(record, column.dataIndex!);
|
||||
let color = '';
|
||||
if (value < 200) {
|
||||
color = 'pink';
|
||||
} else if (value < 201) {
|
||||
color = 'green';
|
||||
} else if (value < 399) {
|
||||
color = 'cyan';
|
||||
} else if (value < 403) {
|
||||
color = 'orange';
|
||||
} else if (value < 501) {
|
||||
color = 'red';
|
||||
}
|
||||
return h(Tag, { color }, () => value);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '请求耗时',
|
||||
dataIndex: 'timeTaken',
|
||||
width: 50,
|
||||
customRender({ record, column }) {
|
||||
let value = _get(record, column.dataIndex!);
|
||||
let color = 'red';
|
||||
if (value < 500) {
|
||||
color = 'green';
|
||||
} else if (value < 1000) {
|
||||
color = 'cyan';
|
||||
} else if (value < 1500) {
|
||||
color = 'orange';
|
||||
}
|
||||
return h(Tag, { color }, () => `${value} ms`);
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user