fix(workbench): reuse system reconnect notice

This commit is contained in:
2026-09-24 14:52:56 +08:00
parent 2191efab2f
commit db778e0bac
2 changed files with 31 additions and 9 deletions
+20 -9
View File
@@ -26,6 +26,7 @@ import {
MapSourceStatusNotice,
MapToolbar,
MapZoom,
dismissMapNotice,
showMapNotice,
type MapToolbarItem,
type MapSourceStatus
@@ -166,6 +167,25 @@ export function MapWorkbenchPage({
ScheduledConditionRecord[]
>([]);
const workbenchSync = useWorkbenchSync(getAccessToken);
const workbenchSyncReconnecting =
workbenchSync.status === "reconnecting" && workbenchSync.snapshot !== null;
useEffect(() => {
const noticeId = "workbench-sync-reconnecting";
if (!workbenchSyncReconnecting) {
dismissMapNotice(noticeId);
return;
}
showMapNotice({
id: noticeId,
tone: "warning",
title: "业务同步正在重连",
message: "当前数据可能陈旧,连接恢复后将自动更新。",
duration: Infinity
});
return () => dismissMapNotice(noticeId);
}, [workbenchSyncReconnecting]);
const {
headerDataTime,
scheduledConditions: runtimeScheduledConditions,
@@ -1166,15 +1186,6 @@ export function MapWorkbenchPage({
onLogout={onLogout}
/>
{workbenchSync.status === "reconnecting" && workbenchSync.snapshot ? (
<div
role="status"
className="absolute left-1/2 top-[3.7rem] z-[70] -translate-x-1/2 rounded-md border border-amber-300/70 bg-amber-50/95 px-3 py-1.5 text-xs font-medium text-amber-900 shadow-xs backdrop-blur"
>
正在重连,业务数据可能陈旧
</div>
) : null}
{analysisResultsPanelOpen || peripheralSamplePanelOpen ? (
<div
aria-hidden="true"
@@ -264,6 +264,17 @@ test("审批动作展示中文参数和证据,viewer 不可审批,冲突后
};
await page.goto("/");
const reconnectNotice = page.locator("[data-sonner-toast]").filter({
hasText: "业务同步正在重连"
});
await expect(reconnectNotice).toBeVisible();
await expect(reconnectNotice).toContainText("当前数据可能陈旧,连接恢复后将自动更新。");
await expect(page.getByText("正在重连,业务数据可能陈旧", { exact: true })).toHaveCount(0);
await page.evaluate(() => document.fonts.ready);
await testInfo.attach("workbench-reconnect-notice", {
body: await reconnectNotice.screenshot({ path: testInfo.outputPath("workbench-reconnect-notice.png") }),
contentType: "image/png"
});
let conditionPanel = await openTask();
await expect(conditionPanel.getByRole("navigation", { name: "工况任务分类" })).toBeVisible();
await expect(conditionPanel.getByRole("button", { name: /定时任务/ })).toContainText("模拟数据");