2022-12-16 11:33:46 +00:00
|
|
|
#![cfg(feature = "wasm_test")]
|
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_router::prelude::*;
|
|
|
|
use gloo::utils::document;
|
2023-05-31 18:57:33 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::str::FromStr;
|
2022-12-16 11:33:46 +00:00
|
|
|
use wasm_bindgen_test::*;
|
|
|
|
|
|
|
|
wasm_bindgen_test_configure!(run_in_browser);
|
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
#[rustfmt::skip]
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
|
|
|
enum Route {
|
|
|
|
#[route("/")]
|
|
|
|
Home {},
|
|
|
|
#[nest("/blog")]
|
|
|
|
#[route("/")]
|
|
|
|
BlogList {},
|
|
|
|
#[route("/:id")]
|
|
|
|
BlogPost { id: usize },
|
|
|
|
}
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
fn App(cx: Scope) -> Element {
|
|
|
|
render!(Router {
|
|
|
|
config: RouterConfiguration {
|
|
|
|
history: Box::<WebHistory<Route>>::default(),
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
#[inline_props]
|
|
|
|
fn Home(cx: Scope) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
h1 { "Home" }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
#[inline_props]
|
|
|
|
fn BlogList(cx: Scope) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
#[inline_props]
|
|
|
|
fn BlogPost(cx: Scope, id: usize) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div { }
|
|
|
|
})
|
|
|
|
}
|
2022-12-16 11:33:46 +00:00
|
|
|
|
2023-05-31 18:57:33 +00:00
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn simple_test() {
|
|
|
|
fn main() {
|
|
|
|
console_error_panic_hook::set_once();
|
|
|
|
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
|
|
|
dioxus_web::launch(App);
|
2022-12-16 11:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
let _ = document();
|
|
|
|
}
|