add 404 page
All checks were successful
build docker container automatically / build (push) Successful in 4m14s
All checks were successful
build docker container automatically / build (push) Successful in 4m14s
This commit is contained in:
30
src/main.rs
30
src/main.rs
@ -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! {
|
||||
|
||||
Reference in New Issue
Block a user