

// 创建toast元素的函数
const createToastElement = (message: string, duration: number = 2000): HTMLDivElement => {
  const toast = document.createElement('div');
  toast.className = 'simple-toast';
  toast.textContent = message;

  // 添加到页面
  document.body.appendChild(toast);

  // 添加显示动画
  setTimeout(() => {
    toast.classList.add('show');
  }, 10);

  // 设置自动移除
  setTimeout(() => {
    toast.classList.remove('show');
    setTimeout(() => {
      if (document.body.contains(toast)) {
        document.body.removeChild(toast);
      }
    }, 30000); // 等待消失动画完成
  }, duration);

  return toast;
};

// 简单的toast函数
export function toast(message: string, duration: number = 2000): void {
  console.log('显示toast:', message);

  if (!message) {
    console.warn('Toast消息为空');
    return;
  }

  try {
    createToastElement(message, duration);
  } catch (error) {
    console.error('Toast显示失败:', error);
  }
}

