'use client'; import { ArrowLeft } from 'lucide-react'; import { Button } from '@/app/components/ui/button'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; interface BackButtonProps { text: string; href: string; } export default function BackButton({ text, href }: BackButtonProps) { const router = useRouter(); const handleBack = () => { // 如果浏览器有历史记录,则返回上一页 if (typeof window !== 'undefined' && window.history.length > 1) { router.back(); } else { // 否则导航到指定页面 router.push(href); } }; return ( ); }