practice_code/web/czr/hooks/error.tsx

43 lines
1.4 KiB
TypeScript
Raw Permalink 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";
import { Template } from "interface/template";
export default new Template({}, ({ args }) => {
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-[--background] transition-colors duration-300">
<div className="text-center">
<h1 className="text-6xl font-bold text-[--foreground] mb-4">
{text}
<span className="animate-pulse">|</span>
</h1>
<p className="text-[--muted-foreground] text-xl">
访
</p>
<button
onClick={() => (window.location.href = "/")}
className="mt-8 px-6 py-3 bg-[--primary] hover:bg-[--primary-foreground] text-[--primary-foreground] hover:text-[--primary] rounded-lg transition-colors duration-300"
>
</button>
</div>
</div>
);
});