| 1 | /* 惩戒页(Punishment pages):500 服务器失联 / 404 迷失之城。 |
| 2 | 复用登录页场景做背景——报错也保持门面体面(自托管场景里这页常是运维第一现场)。 */ |
| 3 | import { Home, RefreshCw } from "lucide-react"; |
| 4 | import { Link } from "@tanstack/react-router"; |
| 5 | import { S } from "../i18n"; |
| 6 | import { Wordmark } from "../ui"; |
| 7 | import { usePageTitle } from "../useTitle"; |
| 8 | import { LoginScene } from "./LoginScene"; |
| 9 | |
| 10 | function PunishmentPage({ |
| 11 | message, |
| 12 | children, |
| 13 | }: { |
| 14 | message: string; |
| 15 | children: React.ReactNode; |
| 16 | }) { |
| 17 | return ( |
| 18 | <div className="min-h-screen flex items-center justify-center px-4"> |
| 19 | <LoginScene /> |
| 20 | <div className="relative z-10 text-center u-rise"> |
| 21 | <h1 className="text-5xl font-normal"> |
| 22 | <Wordmark /> |
| 23 | </h1> |
| 24 | <p className="u-balance mt-4 text-sm text-neutral-400">{message}</p> |
| 25 | <div className="mt-5 flex items-center justify-center gap-4"> |
| 26 | {children} |
| 27 | <a |
| 28 | href={`${S.login.githubUrl}/issues`} |
| 29 | target="_blank" |
| 30 | rel="noreferrer" |
| 31 | className="u-link text-xs" |
| 32 | > |
| 33 | {S.nav.reportIssue} |
| 34 | </a> |
| 35 | </div> |
| 36 | </div> |
| 37 | </div> |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | export function ServerDown() { |
| 42 | usePageTitle(S.app.name, "Punishment 500"); |
| 43 | return ( |
| 44 | <PunishmentPage message={S.nav.serverUnreachable}> |
| 45 | <button |
| 46 | onClick={() => window.location.reload()} |
| 47 | className="u-btn u-btn-ghost px-3.5 py-1.5 text-xs flex items-center gap-1.5" |
| 48 | > |
| 49 | <RefreshCw size={12} /> |
| 50 | {S.nav.refresh} |
| 51 | </button> |
| 52 | </PunishmentPage> |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | export function NotFound() { |
| 57 | usePageTitle(S.app.name, "Punishment 404"); |
| 58 | return ( |
| 59 | <PunishmentPage message={S.nav.notFound}> |
| 60 | <Link to="/" className="u-btn u-btn-ghost px-3.5 py-1.5 text-xs flex items-center gap-1.5"> |
| 61 | <Home size={12} /> |
| 62 | {S.nav.returnHome} |
| 63 | </Link> |
| 64 | </PunishmentPage> |
| 65 | ); |
| 66 | } |