+ ${options.icon ? `
${escapeBannerText(options.icon)}
` : ""}
+ ${options.title ? `
+ ══ ${escapeBannerText(options.title)} ══
+
` : ""}
+ ${options.name ? `
+ ${escapeBannerText(options.name)}
+
` : ""}
+ ${options.body ? `
${renderMultilineText(options.body)}
` : ""}
+ ${options.sub ? `
${renderMultilineText(options.sub)}
` : ""}
+ ${renderButtons(buttons)}
+
+ ${new Date().toLocaleTimeString("zh-CN")}
+
+
+ `;
+
+ document.body.appendChild(banner);
+
+ buttons.forEach((button, index) => {
+ const element = banner.querySelector(`[data-banner-btn="${index}"]`);
+ if (!element) {
+ return;
+ }
+
+ element.addEventListener("click", () => {
+ if (typeof button.onClick === "function") {
+ button.onClick(element, () => closeBannerElement(banner));
+ return;
+ }
+
+ closeBannerElement(banner);
+ });
+ });
+
+ if (autoClose > 0) {
+ window.setTimeout(() => {
+ if (document.getElementById(id)) {
+ closeBannerElement(banner);
+ }
+ }, autoClose);
+ }
+ },
+
+ /**
+ * 关闭指定 ID 的大卡片通知。
+ *
+ * @param {string} [id]
+ * @returns {void}
+ */
+ close(id) {
+ const banner = document.getElementById(id || DEFAULT_BANNER_ID);
+ if (!banner) {
+ return;
+ }
+
+ closeBannerElement(banner);
+ },
+ };
+}
+
+/**
+ * 绑定全局大卡片通知 API。
+ *
+ * @returns {void}
+ */
+export function bindChatBanner() {
+ if (typeof document === "undefined" || window.chatBanner) {
+ return;
+ }
+
+ window.chatBanner = createChatBanner();
+}
diff --git a/resources/views/chat/partials/chat-banner.blade.php b/resources/views/chat/partials/chat-banner.blade.php
index fb32712..9153563 100644
--- a/resources/views/chat/partials/chat-banner.blade.php
+++ b/resources/views/chat/partials/chat-banner.blade.php
@@ -21,177 +21,8 @@
onClick(btn, close): Function
}>
- 从 scripts.blade.php 拆分,确保页面全局组件独立维护。
+ 实际实现已迁移到 resources/js/chat-room/banner.js,由 resources/js/chat-room.js 统一通过 Vite 加载。
@author ChatRoom Laravel
@version 1.0.0
--}}
-
-