feat(platform): unify source status tags
This commit is contained in:
@@ -5,6 +5,7 @@ import { api } from '../api/client';
|
||||
import type { VehicleCoverageRow, VehicleCoverageSummary } from '../api/types';
|
||||
import { DataEmpty } from '../components/DataEmpty';
|
||||
import { PageHeader } from '../components/PageHeader';
|
||||
import { SourceStatusTags } from '../components/SourceStatusTags';
|
||||
import { StatusTag } from '../components/StatusTag';
|
||||
|
||||
function vehicleServiceStatus(row: VehicleCoverageRow) {
|
||||
@@ -33,16 +34,6 @@ function sourceEvidenceText(row: VehicleCoverageRow) {
|
||||
return `${row.onlineSourceCount}/${row.sourceCount} 来源在线`;
|
||||
}
|
||||
|
||||
function sourceStatusLabel(source: { online: boolean; hasRealtime: boolean; lastSeen: string }) {
|
||||
if (source.online) {
|
||||
return { text: '在线', color: 'green' as const };
|
||||
}
|
||||
if (source.hasRealtime || source.lastSeen) {
|
||||
return { text: '离线', color: 'orange' as const };
|
||||
}
|
||||
return { text: '未接入', color: 'grey' as const };
|
||||
}
|
||||
|
||||
function sourceConsistencyAction(row: VehicleCoverageRow, onFilter: (filters: Record<string, string>) => void) {
|
||||
const consistency = row.sourceConsistency;
|
||||
if (!consistency) {
|
||||
@@ -160,12 +151,7 @@ export function Vehicles({
|
||||
title: '来源证据',
|
||||
width: 300,
|
||||
render: (_: unknown, row: VehicleCoverageRow) => (
|
||||
<Space spacing={4} wrap>
|
||||
{(row.sourceStatus?.length ? row.sourceStatus : row.protocols.map((protocol) => ({ protocol, online: false, hasRealtime: true, lastSeen: row.lastSeen }))).map((source) => {
|
||||
const status = sourceStatusLabel(source);
|
||||
return <Tag key={source.protocol} color={status.color}>{source.protocol} {status.text}</Tag>;
|
||||
})}
|
||||
</Space>
|
||||
<SourceStatusTags sourceStatus={row.sourceStatus} protocols={row.protocols} lastSeen={row.lastSeen} />
|
||||
)
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user