Files
web_hghl_h5/src/components/common/back-button.tsx
T
谢宇宁andClaude Opus 5.5 61d0a11dfa Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:51:31 +07:00

20 lines
696 B
TypeScript

"use client";
import { useRouter } from "next/navigation";
export function BackButton({ fallback = "/", className = "" }: { fallback?: string; className?: string }) {
const router = useRouter();
const goBack = () => {
if (window.history.length > 1) router.back();
else router.push(fallback);
};
return (
<button data-component="back-button" type="button" aria-label="返回" onClick={goBack} className={`cursor-pointer size-6 ${className}`}>
<svg viewBox="0 0 24 24" className="size-full" aria-hidden="true">
<path d="M15 5l-7 7 7 7" fill="none" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</button>
);
}