feat:对返回上一页做了处理

This commit is contained in:
许永平
2025-07-05 21:09:28 +08:00
parent 7b29660a51
commit 0385a4cfa9
13 changed files with 317 additions and 23 deletions

View File

@@ -0,0 +1,30 @@
import React from 'react';
import { useThrottledRequestWithLoading } from '../hooks/useThrottledRequest';
interface ThrottledButtonProps {
onClick: () => Promise<any>;
children: React.ReactNode;
delay?: number;
disabled?: boolean;
className?: string;
}
export const ThrottledButton: React.FC<ThrottledButtonProps> = ({
onClick,
children,
delay = 1000,
disabled = false,
className = ''
}) => {
const { throttledRequest, loading } = useThrottledRequestWithLoading(onClick, delay);
return (
<button
onClick={throttledRequest}
disabled={disabled || loading}
className={`px-4 py-2 rounded bg-blue-500 text-white hover:bg-blue-600 disabled:bg-gray-400 disabled:cursor-not-allowed ${className}`}
>
{loading ? '处理中...' : children}
</button>
);
};