mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-06 19:26:48 +08:00
48dcb23ea5
- 创建 ConfirmModal 和 MessageModal 组件 - 更新 App.tsx 使用新的 Modal 组件 - 改进表单验证错误显示 - 提升用户体验和界面一致性
44 lines
910 B
TypeScript
44 lines
910 B
TypeScript
import React from 'react'
|
||
import './AddProviderModal.css'
|
||
|
||
interface MessageModalProps {
|
||
title: string
|
||
message: string
|
||
type?: 'success' | 'error' | 'info'
|
||
onClose: () => void
|
||
}
|
||
|
||
const MessageModal: React.FC<MessageModalProps> = ({
|
||
title,
|
||
message,
|
||
type = 'info',
|
||
onClose
|
||
}) => {
|
||
const getIcon = () => {
|
||
switch (type) {
|
||
case 'success':
|
||
return '✅'
|
||
case 'error':
|
||
return '❌'
|
||
default:
|
||
return 'ℹ️'
|
||
}
|
||
}
|
||
|
||
return (
|
||
<div className="modal-overlay" onClick={onClose}>
|
||
<div className="modal-content" onClick={(e) => e.stopPropagation()}>
|
||
<h2>{getIcon()} {title}</h2>
|
||
<p>{message}</p>
|
||
|
||
<div className="form-actions">
|
||
<button type="button" className="submit-btn" onClick={onClose}>
|
||
确定
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
export default MessageModal |