Init with webapp template
This commit is contained in:
commit
37331cd24d
13 changed files with 2709 additions and 0 deletions
13
app/Cargo.toml
Normal file
13
app/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
api = { version = "0.1.0", path = "../api" }
|
||||
console_log = { version = "1.0.0", features = ["color"] }
|
||||
log = "0.4.17"
|
||||
yew = { version = "0.20.0", features = ["csr"] }
|
||||
yew-router = "0.17.0"
|
||||
8
app/index.html
Normal file
8
app/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
40
app/src/main.rs
Normal file
40
app/src/main.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use log::Level;
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
|
||||
#[derive(Routable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum Route {
|
||||
#[at("/")]
|
||||
Index,
|
||||
#[at("/404")]
|
||||
#[not_found]
|
||||
NotFound,
|
||||
}
|
||||
|
||||
#[function_component]
|
||||
fn App() -> Html {
|
||||
html! {
|
||||
<BrowserRouter>
|
||||
<main>
|
||||
<Switch<Route> render={switch} />
|
||||
</main>
|
||||
</BrowserRouter>
|
||||
}
|
||||
}
|
||||
|
||||
fn switch(route: Route) -> Html {
|
||||
match route {
|
||||
Route::Index => html! {
|
||||
"Index"
|
||||
},
|
||||
Route::NotFound => html! {
|
||||
"Page not found"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
console_log::init_with_level(Level::Debug).unwrap();
|
||||
|
||||
yew::Renderer::<App>::new().render();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue