Skip to content

Commit 6a9929d

Browse files
author
Cairry
committed
update
1 parent 23a2362 commit 6a9929d

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

src/pages/alert/preview/searchViewMetrics.tsx

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,20 @@ export const SearchViewMetrics = ({
6868
throw new Error(res.msg || "请求失败")
6969
}
7070

71-
// 提取所有 result 数据
72-
const allResults = res?.data
73-
?.filter((item: any) => item.status === "success" && item.data?.result?.length > 0)
74-
.flatMap((item: any) => item.data.result)
71+
if (res.data && Array.isArray(res.data) && res.data.length > 0) {
72+
const processedResults = res.data.flatMap(r =>
73+
r.data?.result?.map(item => ({
74+
...item,
75+
// 取最后一个值作为当前值
76+
value: item.values && item.values.length > 0
77+
? item.values[item.values.length - 1]
78+
: (item.value || null)
79+
})) || []
80+
)
81+
setMetrics(processedResults)
82+
}
7583

76-
setMetrics(allResults)
84+
7785
} catch (err) {
7886
setError(err instanceof Error ? err.message : "网络错误")
7987
console.error("Fetch card data error:", err)
@@ -173,23 +181,20 @@ export const SearchViewMetrics = ({
173181
title: '数值',
174182
dataIndex: 'value',
175183
key: 'value',
176-
width: 120,
177-
render: (value: string) => (
178-
<Text style={{
179-
fontSize: '16px',
180-
fontWeight: 'bold',
181-
color: parseFloat(value.replace(/,/g, '')) === 0 ? '#52c41a' : '#1890ff'
182-
}}>
183-
{value}
184-
</Text>
184+
width: 200,
185+
render: (value, record) => (
186+
<Space direction="vertical" size="small" style={{ width: '100%' }}>
187+
<div>
188+
<Text strong style={{ fontSize: '14px' }}>
189+
{value}
190+
</Text>
191+
<Text type="secondary" style={{ fontSize: '12px', marginLeft: '8px' }}>
192+
({record.timestamp})
193+
</Text>
194+
</div>
195+
</Space>
185196
)
186-
},
187-
{
188-
title: '时间戳',
189-
dataIndex: 'timestamp',
190-
key: 'timestamp',
191-
width: 180,
192-
},
197+
}
193198
]
194199

195200

@@ -379,8 +384,8 @@ export const SearchViewMetrics = ({
379384
key: 'card',
380385
label: (
381386
<span>
382-
<AppstoreOutlined />
383-
卡片视图
387+
<AppstoreOutlined style={{ marginRight: '8px' }} />
388+
Card
384389
</span>
385390
),
386391
children: renderCardView(),
@@ -389,8 +394,8 @@ export const SearchViewMetrics = ({
389394
key: 'chart',
390395
label: (
391396
<span>
392-
<LineChartOutlined />
393-
图表视图
397+
<LineChartOutlined style={{ marginRight: '8px' }} />
398+
Graph
394399
</span>
395400
),
396401
children: renderChartView(),

src/pages/exploer/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ export const DataAnalysis = () => {
691691
))}
692692

693693
{/* 底部:添加查询按钮 */}
694-
<div style={{ textAlign: 'center', marginTop: '16px' }}>
694+
{/* <div style={{ textAlign: 'center', marginTop: '16px' }}>
695695
<Button
696696
type="dashed"
697697
icon={<PlusOutlined />}
@@ -701,7 +701,7 @@ export const DataAnalysis = () => {
701701
>
702702
添加查询
703703
</Button>
704-
</div>
704+
</div> */}
705705
</div>
706706
)
707707

0 commit comments

Comments
 (0)