add 404 page
All checks were successful
build docker container automatically / build (push) Successful in 4m14s

This commit is contained in:
2026-04-20 12:12:36 +02:00
parent d74ca76e44
commit 517ecbd359
4 changed files with 51 additions and 2 deletions

View File

@ -1,12 +1,19 @@
use dioxus::prelude::*;
use crate::dioxus_fullstack::FullstackContext;
use tracing::Level;
pub mod config;
use crate::components::toast::ToastProvider;
use crate::views::{Upload, UploadInfo, Home};
use crate::views::{
Upload,
UploadInfo,
Home,
NotFound
};
#[cfg(feature = "server")]
use crate::config::ServerConfig;
@ -17,12 +24,17 @@ mod views;
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
enum Route {
#[layout(ErrorLayout)]
#[route("/")]
Home { },
#[route("/upload/:file")]
UploadInfo { file: String },
#[route("/upload")]
Upload { },
#[route("/:..route")]
NotFound { route: Vec<String> },
}
@ -37,6 +49,22 @@ fn main() {
dioxus::launch(App);
}
#[component]
fn ErrorLayout() -> Element {
rsx! {
ErrorBoundary {
handle_error: move |err: ErrorContext| {
let http_error = FullstackContext::commit_error_status(err.error().unwrap());
match http_error.status {
StatusCode::NOT_FOUND => rsx! { div { "404 - Page not found" } },
_ => rsx! { div { "An unknown error occurred" } },
}
},
Outlet::<Route> {}
}
}
}
#[component]
fn App() -> Element {
rsx! {