flnxi-Wu/components/ui/AlertDialog.tsx
WuYongJie 7dc8d2a528
Some checks failed
CI Check / check (push) Has been cancelled
feat: 统一弹窗系统 & 首页UI优化
- 替换所有浏览器原生弹窗(confirm/alert/prompt)
  - 创建 ConfirmDialog、AlertDialog、PromptDialog 组件
  - 创建 DialogProvider 和 useDialog Hook
  - 替换所有 admin 组件、首页、分享页面中的原生弹窗

- 素材预览面板统一
  - 创建 MaterialPreviewModal 组件
  - 使用统一弹窗组件,统一退出逻辑

- 首页UI统一到三层架构
  - 迁移主要按钮和输入框样式
  - 迁移筛选弹窗中的所有按钮样式
  - 使用 useThemeStyles() Hook

- 更新文档
  - 更新优化记录、优化计划、后续修改、更新日志
2025-11-22 16:20:05 +08:00

66 lines
1.3 KiB
TypeScript

'use client'
import { ReactNode } from 'react'
import Modal from './Modal'
import { useThemeStyles } from '@/lib/ui-styles'
interface AlertDialogProps {
isOpen: boolean
onClose: () => void
title: string
message: string | ReactNode
buttonText?: string
variant?: 'default' | 'success' | 'warning' | 'error'
}
export default function AlertDialog({
isOpen,
onClose,
title,
message,
buttonText = '确定',
variant = 'default',
}: AlertDialogProps) {
const styles = useThemeStyles()
const getButtonStyle = () => {
switch (variant) {
case 'success':
return styles.buttonStyles.success
case 'warning':
return styles.buttonStyles.secondary
case 'error':
return styles.buttonStyles.danger
default:
return styles.buttonStyles.primary
}
}
return (
<Modal
isOpen={isOpen}
onClose={onClose}
title={title}
size="small"
footer={
<button
type="button"
onClick={onClose}
className={`${getButtonStyle()} ${styles.buttonModifiers.compact}`}
>
{buttonText}
</button>
}
>
<div className="py-2">
{typeof message === 'string' ? (
<p className="text-slate-700 dark:text-slate-200">{message}</p>
) : (
message
)}
</div>
</Modal>
)
}