import React, { useEffect } from 'react'; import { Button, Toast } from 'antd-mobile'; import { useCamera } from '../../hooks'; import './index.css'; interface CameraCaptureProps { onCapture: (file: File) => void; onClose?: () => void; } const CameraCapture: React.FC = ({ onCapture, onClose }) => { const { videoRef, canvasRef, isReady, error, start, stop, capture } = useCamera(); useEffect(() => { start(); return () => { stop(); }; }, [start, stop]); const handleCapture = async () => { const file = await capture(); if (file) { onCapture(file); } else { Toast.show({ content: '拍照失败', icon: 'fail' }); } }; if (error) { return (

{error}

); } return (
); }; export default CameraCapture;