feat(platform): unify source status tags

This commit is contained in:
lingniu
2026-07-04 07:34:18 +08:00
parent c528376ef9
commit f93c8d6ccc
4 changed files with 49 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
import { api } from '../api/client';
import type { DashboardSummary, LinkHealth, ProtocolStat, QualityIssueRow, ServiceStatusStat, VehicleCoverageRow, VehicleRealtimeRow, VehicleServiceSummary } from '../api/types';
import { PageHeader } from '../components/PageHeader';
import { SourceStatusTags } from '../components/SourceStatusTags';
import { StatusTag } from '../components/StatusTag';
import { qualityIssueVehicleLookup } from '../domain/vehicleLookup';
@@ -324,11 +325,9 @@ export function Dashboard({ onOpenVehicle, onOpenQuality, onOpenVehicles }: { on
{ title: 'VIN', dataIndex: 'vin', width: 190 },
{
title: '来源证据',
width: 240,
width: 300,
render: (_: unknown, row: VehicleCoverageRow) => (
<Space spacing={4} wrap>
{row.protocols.map((protocol) => <Tag key={protocol} color="blue">{protocol}</Tag>)}
</Space>
<SourceStatusTags sourceStatus={row.sourceStatus} protocols={row.protocols} lastSeen={row.lastSeen} />
)
},
{

View File

@@ -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} />
)
},
{