feat: wrap frontend routes in FrontendLayout via router #[layout] attribute
- All public-facing pages (Home, Archives, Tags, PostDetail, Search, About, HomePage) are now wrapped in #[layout(FrontendLayout)] - Header and Footer stay mounted during page transitions, only the <Outlet> content swaps — eliminates full-page flash/flicker - Login and Register routes moved outside FrontendLayout since they are standalone pages without navigation header - Route order restructured: FrontendLayout block → admin nest → auth pages - Note: #[end_layout]/#[end_nest] must have a variant after them in the enum, otherwise the Routable derive macro fails with 'expected identifier'
This commit is contained in:
parent
e861b8a5be
commit
8845577958
@ -2,6 +2,7 @@ use dioxus::prelude::*;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::components::admin_layout::AdminLayout;
|
use crate::components::admin_layout::AdminLayout;
|
||||||
|
use crate::components::frontend_layout::FrontendLayout;
|
||||||
use crate::context::UserContext;
|
use crate::context::UserContext;
|
||||||
use crate::pages::about::About;
|
use crate::pages::about::About;
|
||||||
use crate::pages::admin::{Admin, Posts, Write};
|
use crate::pages::admin::{Admin, Posts, Write};
|
||||||
@ -17,14 +18,24 @@ use crate::theme::{use_theme_provider, Theme, ThemePreload};
|
|||||||
#[derive(Clone, Routable, Debug, PartialEq)]
|
#[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub enum Route {
|
pub enum Route {
|
||||||
#[route("/")]
|
#[layout(FrontendLayout)]
|
||||||
Home {},
|
#[route("/")]
|
||||||
#[route("/page/:page")]
|
Home {},
|
||||||
HomePage { page: i32 },
|
#[route("/page/:page")]
|
||||||
#[route("/login")]
|
HomePage { page: i32 },
|
||||||
Login {},
|
#[route("/archives")]
|
||||||
#[route("/register")]
|
Archives {},
|
||||||
Register {},
|
#[route("/tags")]
|
||||||
|
Tags {},
|
||||||
|
#[route("/tags/:tag")]
|
||||||
|
TagDetail { tag: String },
|
||||||
|
#[route("/post/:slug")]
|
||||||
|
PostDetail { slug: String },
|
||||||
|
#[route("/search")]
|
||||||
|
Search {},
|
||||||
|
#[route("/about")]
|
||||||
|
About {},
|
||||||
|
#[end_layout]
|
||||||
|
|
||||||
#[nest("/admin")]
|
#[nest("/admin")]
|
||||||
#[layout(AdminLayout)]
|
#[layout(AdminLayout)]
|
||||||
@ -37,18 +48,10 @@ pub enum Route {
|
|||||||
#[end_layout]
|
#[end_layout]
|
||||||
#[end_nest]
|
#[end_nest]
|
||||||
|
|
||||||
#[route("/archives")]
|
#[route("/login")]
|
||||||
Archives {},
|
Login {},
|
||||||
#[route("/tags")]
|
#[route("/register")]
|
||||||
Tags {},
|
Register {},
|
||||||
#[route("/tags/:tag")]
|
|
||||||
TagDetail { tag: String },
|
|
||||||
#[route("/post/:slug")]
|
|
||||||
PostDetail { slug: String },
|
|
||||||
#[route("/search")]
|
|
||||||
Search {},
|
|
||||||
#[route("/about")]
|
|
||||||
About {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user