feat(platform): poll topbar link health

This commit is contained in:
lingniu
2026-07-03 23:01:01 +08:00
parent 909f7d6720
commit b73292b97e

View File

@@ -15,17 +15,25 @@ export default function App() {
const [activeVin, setActiveVin] = useState('LB9A32A24R0LS1426');
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
const refreshOpsHealth = useCallback(() => {
const refreshOpsHealth = useCallback((showError = true) => {
return api.opsHealth()
.then((health) => {
setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length);
return health;
})
.catch((error: Error) => Toast.error(error.message));
.catch((error: Error) => {
if (showError) {
Toast.error(error.message);
}
});
}, []);
useEffect(() => {
refreshOpsHealth();
const timer = window.setInterval(() => {
refreshOpsHealth(false);
}, 60000);
return () => window.clearInterval(timer);
}, [refreshOpsHealth]);
const openVehicle = (vin: string) => {