恢复首页路由,添加归档/标签/搜索/关于路由占位
- router.rs: / 恢复为 HomePage,新增 /archives /tags /search /about - mod.rs: 导出 home 模块 - theme.rs: ThemeToggle 从浮动按钮改为内联样式 - home.rs: 创建空占位文件 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c2d5619855
commit
8b3aab21de
8
src/pages/home.rs
Normal file
8
src/pages/home.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub fn HomePage() -> Element {
|
||||
rsx! {
|
||||
"Home"
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
pub mod admin;
|
||||
pub mod home;
|
||||
pub mod login;
|
||||
pub mod register;
|
||||
|
||||
@ -1,19 +1,29 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::pages::admin::AdminPage;
|
||||
use crate::pages::home::HomePage;
|
||||
use crate::pages::login::LoginPage;
|
||||
use crate::pages::register::RegisterPage;
|
||||
use crate::theme::{Theme, ThemeToggle, use_theme};
|
||||
use crate::theme::{Theme, use_theme};
|
||||
|
||||
#[derive(Clone, Routable, Debug, PartialEq)]
|
||||
pub enum Route {
|
||||
#[route("/")]
|
||||
HomePage {},
|
||||
#[route("/login")]
|
||||
LoginPage {},
|
||||
#[route("/register")]
|
||||
RegisterPage {},
|
||||
#[route("/admin")]
|
||||
AdminPage {},
|
||||
#[route("/archives")]
|
||||
ArchivesPage {},
|
||||
#[route("/tags")]
|
||||
TagsPage {},
|
||||
#[route("/search")]
|
||||
SearchPage {},
|
||||
#[route("/about")]
|
||||
AboutPage {},
|
||||
}
|
||||
|
||||
#[component]
|
||||
@ -27,9 +37,28 @@ pub fn AppRouter() -> Element {
|
||||
rsx! {
|
||||
div {
|
||||
class: theme_class,
|
||||
ThemeToggle {}
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ArchivesPage() -> Element {
|
||||
rsx! { "Archives" }
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn TagsPage() -> Element {
|
||||
rsx! { "Tags" }
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn SearchPage() -> Element {
|
||||
rsx! { "Search" }
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn AboutPage() -> Element {
|
||||
rsx! { "About" }
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ pub fn ThemeToggle() -> Element {
|
||||
|
||||
rsx! {
|
||||
button {
|
||||
class: "fixed top-4 right-4 z-50 p-2 rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors",
|
||||
class: "theme-toggle p-2 rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors",
|
||||
onclick: move |_| theme.set(theme().toggle()),
|
||||
if theme() == Theme::Dark {
|
||||
"🌙"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user