feat(platform): show release in topbar

This commit is contained in:
lingniu
2026-07-04 15:37:48 +08:00
parent ff36cb4bd1
commit d72da88c3f
3 changed files with 19 additions and 3 deletions

View File

@@ -36,6 +36,7 @@ export default function App() {
initialRoute.page === 'quality' ? qualityFiltersFromRoute(initialRoute) : {} initialRoute.page === 'quality' ? qualityFiltersFromRoute(initialRoute) : {}
); );
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null); const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
const [platformRelease, setPlatformRelease] = useState('');
const [currentVehicleStatus, setCurrentVehicleStatus] = useState<VehicleServiceStatus | undefined>(); const [currentVehicleStatus, setCurrentVehicleStatus] = useState<VehicleServiceStatus | undefined>();
const [currentVehicleLabel, setCurrentVehicleLabel] = useState(''); const [currentVehicleLabel, setCurrentVehicleLabel] = useState('');
const [currentVehicleConsistency, setCurrentVehicleConsistency] = useState<VehicleSourceConsistency | undefined>(); const [currentVehicleConsistency, setCurrentVehicleConsistency] = useState<VehicleSourceConsistency | undefined>();
@@ -63,6 +64,7 @@ export default function App() {
return api.opsHealth() return api.opsHealth()
.then((health) => { .then((health) => {
setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length); setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length);
setPlatformRelease(health.runtime?.platformRelease ?? '');
return health; return health;
}) })
.catch((error: Error) => { .catch((error: Error) => {
@@ -404,11 +406,14 @@ export default function App() {
detail: <VehicleDetail vin={activeVin} protocol={activeProtocol} onOpenRealtime={openRealtimeForVehicle} onOpenHistory={openHistoryForVehicle} onOpenRaw={openRawForVehicle} onOpenMileage={openMileageForVehicle} onOpenVehicles={openVehicles} onOpenQuality={openQuality} onOpenHistoryEvidence={openHistoryWithFilters} onOpenRawEvidence={openRawWithFilters} onQueryChange={updateVehicleDetailQuery} />, detail: <VehicleDetail vin={activeVin} protocol={activeProtocol} onOpenRealtime={openRealtimeForVehicle} onOpenHistory={openHistoryForVehicle} onOpenRaw={openRawForVehicle} onOpenMileage={openMileageForVehicle} onOpenVehicles={openVehicles} onOpenQuality={openQuality} onOpenHistoryEvidence={openHistoryWithFilters} onOpenRawEvidence={openRawWithFilters} onQueryChange={updateVehicleDetailQuery} />,
history: <History initialVin={analysisVin} initialProtocol={activeProtocol} initialTab={historyTab} initialFilters={historyFilters} onFiltersChange={updateHistoryFilters} onOpenVehicle={openVehicle} onOpenMileage={openMileageWithFilters} onOpenRaw={openRawWithFilters} />, history: <History initialVin={analysisVin} initialProtocol={activeProtocol} initialTab={historyTab} initialFilters={historyFilters} onFiltersChange={updateHistoryFilters} onOpenVehicle={openVehicle} onOpenMileage={openMileageWithFilters} onOpenRaw={openRawWithFilters} />,
mileage: <Mileage initialVin={analysisVin} initialProtocol={activeProtocol} initialFilters={mileageFilters} onFiltersChange={updateMileageFilters} onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} />, mileage: <Mileage initialVin={analysisVin} initialProtocol={activeProtocol} initialFilters={mileageFilters} onFiltersChange={updateMileageFilters} onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} />,
quality: <Quality onOpenVehicle={openVehicle} onOpenRealtime={openRealtime} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} onOpenMileage={openMileageWithFilters} onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} /> quality: <Quality onOpenVehicle={openVehicle} onOpenRealtime={openRealtime} onOpenHistory={openHistoryWithFilters} onOpenRaw={openRawWithFilters} onOpenMileage={openMileageWithFilters} onHealthLoaded={(health) => {
setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length);
setPlatformRelease(health.runtime?.platformRelease ?? '');
}} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} />
}; };
return ( return (
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} onChange={navigatePage} onVehicleSearch={openVehicle}> <AppShell activePage={activePage} linkIssueCount={linkIssueCount} platformRelease={platformRelease} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} onChange={navigatePage} onVehicleSearch={openVehicle}>
{pages[activePage]} {pages[activePage]}
</AppShell> </AppShell>
); );

View File

@@ -36,6 +36,7 @@ function linkHealthClassName(count: number | null) {
export function AppShell({ export function AppShell({
activePage, activePage,
linkIssueCount, linkIssueCount,
platformRelease,
currentVehicleStatus, currentVehicleStatus,
currentVehicleLabel, currentVehicleLabel,
currentVehicleConsistency, currentVehicleConsistency,
@@ -45,6 +46,7 @@ export function AppShell({
}: { }: {
activePage: PageKey; activePage: PageKey;
linkIssueCount: number | null; linkIssueCount: number | null;
platformRelease?: string;
currentVehicleStatus?: VehicleServiceStatus; currentVehicleStatus?: VehicleServiceStatus;
currentVehicleLabel?: string; currentVehicleLabel?: string;
currentVehicleConsistency?: VehicleSourceConsistency; currentVehicleConsistency?: VehicleSourceConsistency;
@@ -107,6 +109,7 @@ export function AppShell({
</Tag> </Tag>
) : null} ) : null}
<Tag color="blue"></Tag> <Tag color="blue"></Tag>
{platformRelease ? <Tag color="blue"> {platformRelease}</Tag> : null}
<Tag color="grey"> / </Tag> <Tag color="grey"> / </Tag>
<Tag color={amapConfigured ? 'green' : 'orange'}>{amapConfigured ? '地图就绪' : '地图待配置'}</Tag> <Tag color={amapConfigured ? 'green' : 'orange'}>{amapConfigured ? '地图就绪' : '地图待配置'}</Tag>
<Button size="small" aria-label="顶部实时监控" onClick={() => onChange('realtime')}></Button> <Button size="small" aria-label="顶部实时监控" onClick={() => onChange('realtime')}></Button>

View File

@@ -23,7 +23,14 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
return { return {
ok: true, ok: true,
json: async () => ({ json: async () => ({
data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }, data: {
linkHealth: [],
kafkaLag: 0,
redisOnlineKeys: 0,
tdengineWritable: true,
mysqlWritable: true,
runtime: { requestTimeoutMs: 5000, platformRelease: 'platform-20260704153357' }
},
traceId: 'trace-test', traceId: 'trace-test',
timestamp: 1783094400000 timestamp: 1783094400000
}) })
@@ -72,6 +79,7 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
render(<App />); render(<App />);
expect(await screen.findByText('地图就绪')).toBeInTheDocument(); expect(await screen.findByText('地图就绪')).toBeInTheDocument();
expect(screen.getByText('版本 platform-20260704153357')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '顶部实时监控' })); fireEvent.click(screen.getByRole('button', { name: '顶部实时监控' }));
expect(window.location.hash).toBe('#/realtime'); expect(window.location.hash).toBe('#/realtime');
fireEvent.click(screen.getByRole('button', { name: '顶部轨迹回放' })); fireEvent.click(screen.getByRole('button', { name: '顶部轨迹回放' }));