|
|
@@ -1,5 +1,9 @@
|
|
|
import React from 'react';
|
|
|
import { useRouteError, useNavigate } from 'react-router';
|
|
|
+import { AlertCircle, RotateCcw, Home } from 'lucide-react';
|
|
|
+import { Button } from '@/client/components/ui/button';
|
|
|
+import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/client/components/ui/card';
|
|
|
+import { Alert, AlertDescription, AlertTitle } from '@/client/components/ui/alert';
|
|
|
|
|
|
export const ErrorPage = () => {
|
|
|
const navigate = useNavigate();
|
|
|
@@ -7,43 +11,55 @@ export const ErrorPage = () => {
|
|
|
const errorMessage = error?.statusText || error?.message || '未知错误';
|
|
|
|
|
|
return (
|
|
|
- <div className="flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 p-4">
|
|
|
- <div className="w-full max-w-md bg-white dark:bg-gray-800 rounded-xl shadow-lg overflow-hidden transition-all duration-300 hover:shadow-xl">
|
|
|
- <div className="bg-red-50 dark:bg-red-900/30 px-6 py-4 border-b border-red-100 dark:border-red-800">
|
|
|
- <h1 className="text-2xl font-bold text-red-600 dark:text-red-400">发生错误</h1>
|
|
|
- </div>
|
|
|
- <div className="p-6">
|
|
|
- <div className="flex items-start mb-4">
|
|
|
- <div className="flex-shrink-0 bg-red-100 dark:bg-red-900/50 p-3 rounded-full">
|
|
|
- <svg className="w-8 h-8 text-red-500 dark:text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
|
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
|
- </svg>
|
|
|
+ <div className="flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-900 dark:to-slate-800 p-4">
|
|
|
+ <Card className="w-full max-w-md border-0 shadow-xl">
|
|
|
+ <CardHeader className="bg-destructive/10">
|
|
|
+ <CardTitle className="flex items-center space-x-2 text-destructive">
|
|
|
+ <AlertCircle className="h-6 w-6" />
|
|
|
+ <span>发生错误</span>
|
|
|
+ </CardTitle>
|
|
|
+ <CardDescription>
|
|
|
+ 抱歉,页面加载时遇到了问题
|
|
|
+ </CardDescription>
|
|
|
+ </CardHeader>
|
|
|
+
|
|
|
+ <CardContent className="space-y-4">
|
|
|
+ <Alert variant="destructive">
|
|
|
+ <AlertCircle className="h-4 w-4" />
|
|
|
+ <AlertTitle>错误详情</AlertTitle>
|
|
|
+ <AlertDescription>
|
|
|
+ {error?.message || '未知错误'}
|
|
|
+ </AlertDescription>
|
|
|
+ </Alert>
|
|
|
+
|
|
|
+ {error?.stack && (
|
|
|
+ <div className="space-y-2">
|
|
|
+ <h4 className="text-sm font-medium text-muted-foreground">技术信息</h4>
|
|
|
+ <pre className="text-xs text-muted-foreground bg-muted/50 p-3 rounded-lg overflow-x-auto max-h-40">
|
|
|
+ {error.stack}
|
|
|
+ </pre>
|
|
|
</div>
|
|
|
- <div className="ml-4">
|
|
|
- <h3 className="text-lg font-medium text-gray-900 dark:text-white">{error?.message || '未知错误'}</h3>
|
|
|
- {error?.stack && (
|
|
|
- <pre className="mt-2 text-xs text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 p-3 rounded overflow-x-auto max-h-40">
|
|
|
- {error.stack}
|
|
|
- </pre>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="flex gap-4">
|
|
|
- <button
|
|
|
- onClick={() => navigate(0)}
|
|
|
- className="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors duration-200"
|
|
|
- >
|
|
|
- 重新加载
|
|
|
- </button>
|
|
|
- <button
|
|
|
- onClick={() => navigate('/')}
|
|
|
- className="inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors duration-200"
|
|
|
- >
|
|
|
- 返回首页
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ )}
|
|
|
+ </CardContent>
|
|
|
+
|
|
|
+ <CardFooter className="flex gap-2">
|
|
|
+ <Button
|
|
|
+ onClick={() => navigate(0)}
|
|
|
+ className="flex-1"
|
|
|
+ variant="outline"
|
|
|
+ >
|
|
|
+ <RotateCcw className="h-4 w-4 mr-2" />
|
|
|
+ 重新加载
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ onClick={() => navigate('/')}
|
|
|
+ className="flex-1"
|
|
|
+ >
|
|
|
+ <Home className="h-4 w-4 mr-2" />
|
|
|
+ 返回首页
|
|
|
+ </Button>
|
|
|
+ </CardFooter>
|
|
|
+ </Card>
|
|
|
</div>
|
|
|
);
|
|
|
};
|