2022-12-16 10:55:20 +00:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
2022-01-18 01:19:12 +00:00
|
|
|
use dioxus::prelude::*;
|
2022-12-16 10:55:20 +00:00
|
|
|
use dioxus_router::prelude::*;
|
2022-01-18 01:19:12 +00:00
|
|
|
|
|
|
|
fn main() {
|
2022-07-09 19:15:20 +00:00
|
|
|
dioxus_desktop::launch(app);
|
2022-01-18 01:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
|
|
cx.render(rsx! (
|
2022-01-18 01:20:36 +00:00
|
|
|
div {
|
2022-01-18 01:19:12 +00:00
|
|
|
p {
|
2022-07-09 19:15:20 +00:00
|
|
|
a { href: "http://dioxuslabs.com/", "Default link - links outside of your app" }
|
2022-01-18 01:19:12 +00:00
|
|
|
}
|
|
|
|
p {
|
|
|
|
a {
|
|
|
|
href: "http://dioxuslabs.com/",
|
2022-01-18 06:52:14 +00:00
|
|
|
prevent_default: "onclick",
|
2022-07-09 19:15:20 +00:00
|
|
|
onclick: |_| println!("Hello Dioxus"),
|
2022-03-05 20:25:09 +00:00
|
|
|
"Custom event link - links inside of your app",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
div {
|
2023-06-02 17:33:47 +00:00
|
|
|
Router {}
|
2022-01-18 01:19:12 +00:00
|
|
|
}
|
|
|
|
))
|
|
|
|
}
|
2022-12-16 10:55:20 +00:00
|
|
|
|
2023-06-02 17:33:47 +00:00
|
|
|
#[derive(Routable, Clone)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
enum Route {
|
|
|
|
#[layout(Header)]
|
|
|
|
#[route("/")]
|
|
|
|
Home {},
|
|
|
|
#[route("/settings")]
|
|
|
|
Settings {},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline_props]
|
|
|
|
fn Header(cx: Scope) -> Element {
|
|
|
|
render! {
|
|
|
|
h1 { "Your app here" }
|
|
|
|
ul {
|
|
|
|
li { Link { target: Route::Home {}, "home" } }
|
|
|
|
li { Link { target: Route::Settings {}, "settings" } }
|
|
|
|
}
|
|
|
|
Outlet {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline_props]
|
2022-12-16 10:55:20 +00:00
|
|
|
fn Home(cx: Scope) -> Element {
|
|
|
|
render!(h1 { "Home" })
|
|
|
|
}
|
|
|
|
|
2023-06-02 17:33:47 +00:00
|
|
|
#[inline_props]
|
2022-12-16 10:55:20 +00:00
|
|
|
fn Settings(cx: Scope) -> Element {
|
|
|
|
render!(h1 { "Settings" })
|
|
|
|
}
|