/** * toast-stack.js — 电机控制台堆叠 toast(#toastContainer) * * motor 页不用 common/toast.js 的单 toast 条,而是左下角堆叠条。 * setQuietMode 从 utils.js re-export,保证全仓只有一份实现。 */ "use strict"; import { setQuietMode } from "./utils.js"; export { setQuietMode }; /** @description 创建电机页 toast 工厂。默认容器 #toastContainer。 */ export function createToastStack(containerSelector = "#toastContainer") { const $ = (s) => document.querySelector(s); return function toast(msg, type = "ok") { const host = $(containerSelector); if (!host) return; const el = document.createElement("div"); el.className = `toast ${type}`; const ledCls = type === "ok" ? "led-on" : type === "warn" ? "led-warn" : "led-err"; el.innerHTML = ``; el.lastElementChild.textContent = msg; host.appendChild(el); setTimeout(() => { el.classList.add("out"); setTimeout(() => el.remove(), 220); }, 3000); }; }