"use client"; import { ServerCrash, Home, RefreshCw } from "lucide-react"; import Link from "next/link"; import { useErrorStore, ERROR_COLORS } from "@/stores/error-store"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; /** * 服务器错误 (500) 全屏错误页面组件 * 当 API 返回 500 错误时显示 * 消息:"服务器暂时不可用,请稍后重试" * 包含 "返回首页" 按钮 */ export function ServerError(): React.ReactElement | null { const { isServerError, serverErrorMessage, clearServerError } = useErrorStore(); const handleRetry = (): void => { clearServerError(); // 刷新页面尝试重新加载 if (typeof window !== "undefined") { window.location.reload(); } }; // 没有服务器错误时不显示 if (!isServerError) { return null; } return (
{serverErrorMessage}
{/* 操作按钮 */}错误代码: 500 Internal Server Error
{serverErrorMessage}
{/* 按钮 */}