import { useState } from "react"; import { dismissMapNotice, showMapNotice, type MapNoticeOptions } from "@/features/map/core"; import { Button } from "@/shared/ui/button"; const samples = [ { key: "info", label: "信息通知", tone: "info", title: "地图视图已更新", message: "已切换到当前项目的管网视图。", lifetime: "3.2 秒后关闭" }, { key: "success", label: "成功通知", tone: "success", title: "操作已完成", message: "当前管网视图已导出,可以继续分析。", lifetime: "3.2 秒后关闭" }, { key: "warning", label: "警告通知", tone: "warning", title: "部分监测数据延迟", message: "最新读数尚未到达,请稍后查看。", lifetime: "手动关闭" }, { key: "error", label: "错误通知", tone: "error", title: "管网数据加载失败", message: "暂时无法连接数据源,请检查连接后重试。", lifetime: "手动关闭" }, { key: "loading", label: "加载通知", tone: "loading", title: "正在加载管网", message: "正在准备图层和监测数据,请稍候。", lifetime: "等待完成" } ] satisfies (MapNoticeOptions & { key: string; label: string; lifetime: string })[]; const extraKeys = ["report", "task", "long", ...Array.from({ length: 6 }, (_, index) => `batch-${index}`)]; const noticeId = (key: string) => `dev-notice:${key}`; export function NoticeDevTools() { const [feedback, setFeedback] = useState(""); const [loading, setLoading] = useState(false); function showLinked(key: string, target: "报告" | "任务", message?: string) { showMapNotice({ id: noticeId(key), tone: target === "报告" ? "success" : "warning", title: `${target === "报告" ? "调查报告已更新" : "调查任务待处理"} · 测试`, message: message ?? (target === "报告" ? "城南片区压力异常调查报告已更新,可查看分析结论与处置建议。" : "新收到一项管网异常调查任务,请查看现场情况与待办事项。"), actionLabel: `查看${target}`, onAction: () => setFeedback(`已触发“查看${target}”测试操作,通知仍保留。`) }); } function clearSamples() { [...samples.map((sample) => sample.key), ...extraKeys].forEach((key) => dismissMapNotice(noticeId(key))); setLoading(false); setFeedback("已清除测试通知。"); } return (

本地样例,仅当前页面生效。报告和任务入口只记录点击反馈,不创建真实业务数据。

通知类型

{samples.map(({ key, label, lifetime, ...options }) => ( ))}

报告与任务入口

带操作入口的通知保留至手动关闭,点击查看后继续保留。

布局与堆叠

{feedback ?

{feedback}

: null}
); }