yggdrasil/pages/
not_found.rs1use dioxus::prelude::*;
9
10use crate::router::Route;
11
12#[component]
28pub fn NotFound(segments: Vec<String>) -> Element {
29 let _ = segments;
30
31 #[cfg(feature = "server")]
33 {
34 dioxus::fullstack::FullstackContext::commit_http_status(
35 http::StatusCode::NOT_FOUND,
36 Some("Page Not Found".to_string()),
37 );
38 }
39
40 rsx! {
41 div { class: "flex flex-col items-center justify-center text-center min-h-[50vh] md:min-h-[55vh] px-6",
42 div { class: "relative mb-2",
44 span { class: "text-[140px] md:text-[180px] font-bold leading-none tracking-tighter text-paper-tertiary/[0.08] dark:text-paper-tertiary/[0.06] select-none",
45 "404"
46 }
47 }
48
49 span { class: "text-sm font-medium tracking-[0.2em] uppercase text-paper-secondary mb-6",
51 "Page Not Found"
52 }
53
54 div { class: "w-12 h-px bg-paper-border mb-8" }
56
57 h1 { class: "text-xl md:text-2xl font-medium text-paper-primary mb-3",
59 "页面未找到"
60 }
61 p { class: "text-sm md:text-base text-paper-secondary max-w-sm leading-relaxed mb-10",
62 "这个页面似乎走丢了,或者从未存在过。"
63 }
64
65 button {
70 r#type: "button",
71 onclick: move |_| {
72 if let Some(ctx) = try_consume_context::<ErrorContext>() {
73 ctx.clear_errors();
74 }
75 let _ = dioxus::router::navigator().push(Route::Home {});
76 },
77 class: "group inline-flex items-center gap-2 px-5 py-2.5 text-sm font-medium text-paper-primary bg-paper-entry border border-paper-border rounded-lg hover:border-paper-secondary hover:bg-paper-border transition-all cursor-pointer",
78 svg {
79 xmlns: "http://www.w3.org/2000/svg",
80 width: "16",
81 height: "16",
82 view_box: "0 0 24 24",
83 fill: "none",
84 stroke: "currentColor",
85 stroke_width: "2",
86 stroke_linecap: "round",
87 stroke_linejoin: "round",
88 class: "transition-transform group-hover:-translate-x-0.5",
89 path { d: "M19 12H5M12 19l-7-7 7-7" }
90 }
91 "返回首页"
92 }
93 }
94 }
95}