'use client'; import React, { useEffect, useRef } from 'react'; import { createRoot, Root } from 'react-dom/client'; type QueueStatus = 'waiting' | 'process' | string; interface H5QueueNotificationProps { position: number; estimatedMinutes: number; status: QueueStatus; onCancel?: () => void; onRefresh?: () => void; onClose?: () => void; } function QueueNotificationModal(props: H5QueueNotificationProps) { const { position, estimatedMinutes, status, onCancel, onClose } = props; const containerRef = useRef(null); // 禁用 ESC 关闭,保留空 effect 结构便于未来拓展 useEffect(() => { return () => {}; }, []); useEffect(() => { // Prevent background scroll on mobile while modal is open const originalOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = originalOverflow; }; }, []); const message = status === 'process' ? 'Your work is being produced. Please wait until it is completed before creating a new work.' : `Your work is waiting for production at the ${position} position`; return (
{/* 去除右上角关闭按钮,避免除取消以外的关闭路径 */}
🎬

Queue Reminder

{message}

{status !== 'process' && (
Position
#{position}
ETA
~{estimatedMinutes} min
)}
{status !== 'process' && ( )}
); } /** * Opens a lightweight H5-styled dark modal queue notification. * @param {number} position - Current queue position. * @param {number} estimatedMinutes - Estimated waiting minutes. * @param {QueueStatus} status - Queue status: 'waiting' | 'process' | string. * @param {() => void} onCancel - Callback when user confirms cancel. * @returns {() => void} - Close function to dismiss the modal programmatically. */ export function showQueueNotification( position: number, estimatedMinutes: number, status: QueueStatus, onCancel?: () => void, onRefresh?: () => void ): () => void { if (typeof window === 'undefined' || typeof document === 'undefined') { return () => {}; } const mount = document.createElement('div'); mount.setAttribute('data-alt', 'queue-root'); document.body.appendChild(mount); let root: Root | null = null; try { root = createRoot(mount); } catch { // Fallback cleanup if root creation fails document.body.removeChild(mount); return () => {}; } const close = () => { try { root?.unmount(); } finally { if (mount.parentNode) { mount.parentNode.removeChild(mount); } } }; root.render( ); return close; }