Files
no-whatever/src/app/error.tsx
T
kurihada 455b9e04d8 refactor: 提取 Button 组件,统一按钮变体、尺寸和加载状态
新增 Button.tsx 支持 5 种变体(primary/secondary/danger/ghost/purple)、
3 种尺寸(sm/md/lg)、pill/rounded 形状及内置 loading 状态,
替换 8 个文件中 16 处重复的按钮样板代码。
2026-02-26 18:39:14 +08:00

52 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect } from "react";
import { motion } from "framer-motion";
import { AlertTriangle, RotateCcw, Home } from "lucide-react";
import Button from "@/components/Button";
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
console.error("[ErrorBoundary]", error);
}, [error]);
return (
<div className="flex min-h-dvh flex-col items-center justify-center bg-background px-6">
<motion.div
className="flex flex-col items-center text-center"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
>
<motion.div
className="relative flex h-20 w-20 items-center justify-center"
animate={{ y: [0, -4, 0] }}
transition={{ duration: 2.5, repeat: Infinity, ease: "easeInOut" }}
>
<div className="absolute inset-0 rounded-2xl bg-rose-500/15 blur-lg" />
<AlertTriangle size={36} className="relative text-rose-400/80" strokeWidth={1.5} />
</motion.div>
<h1 className="mt-6 text-xl font-bold text-heading"></h1>
<p className="mt-2 max-w-xs text-sm text-muted">
</p>
<div className="mt-8 flex gap-3">
<Button onClick={reset} variant="danger" icon={<RotateCcw size={15} />}>
</Button>
<Button onClick={() => window.location.href = "/"} variant="secondary" icon={<Home size={15} />}>
</Button>
</div>
</motion.div>
</div>
);
}