Files
DCU_DesktopController/js/common/toast-stack.js
T
cbb 261caf50b7 refactor(motor): P1 拆分 main.js + 收敛连接/总线状态机
R4 外提 scope/ota/seq/conn-poll;R5 waitVersion/queryNodeIdParam 下沉
transport;R6 ecat-bus 单点 bootstrap;R7 toast-stack + utils 去重。
main.js 4647→~1894 行。?v= 已 bump 20260924a。
2026-09-21 02:26:39 +08:00

28 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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 = `<span class="led ${ledCls}" style="width:7px;height:7px"></span><span></span>`;
el.lastElementChild.textContent = msg;
host.appendChild(el);
setTimeout(() => { el.classList.add("out"); setTimeout(() => el.remove(), 220); }, 3000);
};
}