This commit is contained in:
SunYF
2026-10-26 16:32:35 +08:00
parent 4b14f9540a
commit f86feb2271
99 changed files with 1652 additions and 521 deletions
@@ -129,8 +129,18 @@ export class DashboardDataService {
headers: { 'X-API-TOKEN': this.token },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const raw = unwrapPayload(await res.json()) as Partial<DashboardData>;
this.accept(raw, 'polling');
const raw = unwrapPayload(await res.json());
// 看板刷新间隔由 MES 配置项 dashboard.refresh.seconds 驱动(仅轮询兜底间隔)。
// 收到合法值即动态更新轮询周期并重启定时器(SSE 实时通道可用时不依赖此值)。
const rs = (raw as Record<string, unknown>)?.refreshSeconds;
if (typeof rs === 'number' && rs >= 1 && rs <= 10) {
const ms = Math.round(rs * 1000);
if (ms !== config.pollIntervalMs) {
config.pollIntervalMs = ms;
this.startPolling();
}
}
this.accept(raw as Partial<DashboardData>, 'polling');
} catch (err) {
if (!this.running) return;
// 已处于演示模式且后端仍不可达时,不再重复弹错/重发演示数据