first commit
This commit is contained in:
19
frontend/Cargo.toml
Normal file
19
frontend/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "frontend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
console_error_panic_hook = "0.1.7"
|
||||
env_logger = "0.9.0"
|
||||
gloo-net = "^0.2"
|
||||
log = "0.4"
|
||||
console_log = { version = "0.2", features = ["color"] }
|
||||
wasm-bindgen-futures = "^0.4"
|
||||
wasm-logger = "0.2.0"
|
||||
sycamore = {version = "0.8.0-beta.7", features = ["suspense"]}
|
||||
sycamore-router = "0.8.0-beta.7"
|
||||
#yew = "0.19.3"
|
||||
#yew-router = "0.16.0"
|
||||
6
frontend/Trunk.toml
Normal file
6
frontend/Trunk.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[build]
|
||||
target = "index.html"
|
||||
dist = "../dist"
|
||||
|
||||
[[proxy]]
|
||||
backend = "http://[::1]:8081/api/"
|
||||
10
frontend/index.html
Normal file
10
frontend/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
|
||||
<title>Sycamore App</title>
|
||||
<base href="/"/>
|
||||
</head>
|
||||
<body>loading...</body>
|
||||
</html>
|
||||
61
frontend/src/main.rs
Normal file
61
frontend/src/main.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use gloo_net::http::Request;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
use sycamore::prelude::*;
|
||||
use sycamore::suspense::Suspense;
|
||||
use sycamore_router::{Route, Router, RouterProps};
|
||||
use log::Level;
|
||||
|
||||
#[derive(Route)]
|
||||
enum AppRoutes {
|
||||
#[to("/")]
|
||||
Home,
|
||||
#[to("/hello-server")]
|
||||
HelloServer,
|
||||
#[not_found]
|
||||
NotFound,
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App<G: Html>(cx: Scope) -> View<G> {
|
||||
view! {cx,
|
||||
div{"Test"}
|
||||
/*
|
||||
Router {
|
||||
integration: {HistoryIntegration::new()},
|
||||
view: |cx, route: &ReadSignal<AppRoutes>| {
|
||||
view! {
|
||||
div(class="app") {
|
||||
(match route.get().as_ref() {
|
||||
AppRoutes::Home => view! { cx,
|
||||
"This is the index page"
|
||||
},
|
||||
AppRoutes::HelloServer => view! { cx,
|
||||
"About this website"
|
||||
},
|
||||
AppRoutes::NotFound => view! { cx,
|
||||
"404 Not Found"
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
#[component(HelloServer<G>)]
|
||||
fn HelloServer<G: Html>(cx: Scope) -> View<G> {
|
||||
|
||||
view! {cx,
|
||||
div{"No server response"}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
console_log::init_with_level(log::Level::Debug).unwrap();
|
||||
|
||||
sycamore::render(|cx| view! { cx, App {} });
|
||||
//sycamore::render(|cx| App(cx));
|
||||
}
|
||||
Reference in New Issue
Block a user