echoes/frontend/hooks/error.tsx

44 lines
1.3 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.

import React, { useState, useEffect } from "react";
const ErrorPage = () => {
const [text, setText] = useState("");
const fullText = "404 - 页面不见了 :(";
const typingSpeed = 100;
useEffect(() => {
let currentIndex = 0;
const typingEffect = setInterval(() => {
if (currentIndex < fullText.length) {
setText(fullText.slice(0, currentIndex + 1));
currentIndex++;
} else {
clearInterval(typingEffect);
}
}, typingSpeed);
return () => clearInterval(typingEffect);
}, []);
return (
<div className="min-h-screen flex items-center justify-center bg-custom-bg-light dark:bg-custom-bg-dark transition-colors duration-300">
<div className="text-center">
<h1 className="text-6xl font-bold text-custom-title-light dark:text-custom-title-dark mb-4">
{text}
<span className="animate-pulse">|</span>
</h1>
<p className="text-custom-p-light dark:text-custom-p-dark text-xl">
访
</p>
<button
onClick={() => (window.location.href = "/")}
className="mt-8 px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors duration-300"
>
</button>
</div>
</div>
);
};
export default ErrorPage;