use crate::playbar::PlayBar; use crate::playbar::CustomTitle; use crate::playstatus::PlayStatus; use crate::queue::Queue; use leptos::*; use leptos::logging::*; use leptos_meta::*; use leptos_router::*; use crate::pages::login::*; use crate::pages::signup::*; use crate::error_template::{AppError, ErrorTemplate}; use crate::auth::get_logged_in_user; use crate::models::User; pub type LoggedInUserResource = Resource<(), Option>; #[component] pub fn App() -> impl IntoView { // Provides context that manages stylesheets, titles, meta tags, etc. provide_meta_context(); let play_status = PlayStatus::default(); let play_status = create_rw_signal(play_status); let upload_open = create_rw_signal(false); // A resource that fetches the logged in user // This will not automatically refetch, so any login/logout related code // should call `refetch` on this resource let logged_in_user: LoggedInUserResource = create_resource(|| (), |_| async { get_logged_in_user().await .inspect_err(|e| { error!("Error getting logged in user: {:?}", e); }) .ok() .flatten() }); view! { // injects a stylesheet into the document // id=leptos means cargo-leptos will hot-reload this stylesheet // sets the document title // content for this welcome page } .into_view() }>
}> } /> } />
} } use crate::components::sidebar::*; use crate::components::dashboard::*; use crate::components::search::*; use crate::components::personal::*; use crate::components::upload::*; /// Renders the home page of your application. #[component] fn HomePage(play_status: RwSignal, upload_open: RwSignal) -> impl IntoView { view! {
// This will render the child route components
} } /// 404 - Not Found #[component] fn NotFound() -> impl IntoView { // set an HTTP status code 404 // this is feature gated because it can only be done during // initial server-side rendering // if you navigate to the 404 page subsequently, the status // code will not be set because there is not a new HTTP request // to the server #[cfg(feature = "ssr")] { // this can be done inline because it's synchronous // if it were async, we'd use a server function let resp = expect_context::(); resp.set_status(axum::http::StatusCode::NOT_FOUND); } view! {

"Not Found"

} }