feat: add 404 Not Found page
- Add NotFound component with elegant design - Register catch-all route in router - Add skeleton placeholder for NotFound route - Remove unused design-taste-frontend skill
This commit is contained in:
parent
a59a58b41d
commit
2f433e8f11
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@ fn route_skeleton(route: &Route) -> Element {
|
||||
Route::Tags {} | Route::TagDetail { .. } => rsx! { DelayedSkeleton { TagsSkeleton {} } },
|
||||
Route::Search {} => rsx! { DelayedSkeleton { SearchSkeleton {} } },
|
||||
Route::PostDetail { .. } => rsx! { DelayedSkeleton { PostDetailSkeleton {} } },
|
||||
Route::NotFound { .. } => rsx! { div { class: "py-20 md:py-28" } },
|
||||
_ => rsx! { DelayedSkeleton { HomeSkeleton {} } },
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ pub mod admin;
|
||||
pub mod archives;
|
||||
pub mod home;
|
||||
pub mod login;
|
||||
pub mod not_found;
|
||||
pub mod post_detail;
|
||||
pub mod register;
|
||||
pub mod search;
|
||||
|
||||
56
src/pages/not_found.rs
Normal file
56
src/pages/not_found.rs
Normal file
@ -0,0 +1,56 @@
|
||||
use dioxus::prelude::*;
|
||||
use dioxus::router::components::Link;
|
||||
|
||||
use crate::router::Route;
|
||||
|
||||
#[component]
|
||||
pub fn NotFound(segments: Vec<String>) -> Element {
|
||||
let _ = segments;
|
||||
|
||||
rsx! {
|
||||
div { class: "flex flex-col items-center justify-center text-center min-h-[50vh] md:min-h-[55vh] px-6",
|
||||
// 巨大的装饰性 404,作为视觉锚点
|
||||
div { class: "relative mb-2",
|
||||
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",
|
||||
"404"
|
||||
}
|
||||
}
|
||||
|
||||
// 状态标签
|
||||
span { class: "text-sm font-medium tracking-[0.2em] uppercase text-paper-secondary mb-6",
|
||||
"Page Not Found"
|
||||
}
|
||||
|
||||
// 分隔线
|
||||
div { class: "w-12 h-px bg-paper-border mb-8" }
|
||||
|
||||
// 错误信息
|
||||
h1 { class: "text-xl md:text-2xl font-medium text-paper-primary mb-3",
|
||||
"页面未找到"
|
||||
}
|
||||
p { class: "text-sm md:text-base text-paper-secondary max-w-sm leading-relaxed mb-10",
|
||||
"这个页面似乎走丢了,或者从未存在过。"
|
||||
}
|
||||
|
||||
// 返回首页
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
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",
|
||||
svg {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
width: "16",
|
||||
height: "16",
|
||||
view_box: "0 0 24 24",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
stroke_width: "2",
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
class: "transition-transform group-hover:-translate-x-0.5",
|
||||
path { d: "M19 12H5M12 19l-7-7 7-7" }
|
||||
}
|
||||
"返回首页"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,7 @@ use crate::pages::admin::{Admin, Posts, Write, WriteEdit};
|
||||
use crate::pages::archives::Archives;
|
||||
use crate::pages::home::{Home, HomePage};
|
||||
use crate::pages::login::Login;
|
||||
use crate::pages::not_found::NotFound;
|
||||
use crate::pages::post_detail::PostDetail;
|
||||
use crate::pages::register::Register;
|
||||
use crate::pages::search::Search;
|
||||
@ -35,6 +36,8 @@ pub enum Route {
|
||||
Search {},
|
||||
#[route("/about")]
|
||||
About {},
|
||||
#[route("/:..segments")]
|
||||
NotFound { segments: Vec<String> },
|
||||
#[end_layout]
|
||||
|
||||
#[nest("/admin")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user