|
@@ -3,6 +3,9 @@ use leptos::{ev::SubmitEvent, prelude::*};
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
+// Import a css file's classes:
|
|
|
+stylance::import_crate_style!(header_styles, "src/styles/header.module.css");
|
|
|
+
|
|
|
#[wasm_bindgen]
|
|
|
extern "C" {
|
|
|
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
|
|
@@ -32,6 +35,8 @@ pub fn App() -> impl IntoView {
|
|
|
set_name.set(v);
|
|
|
};
|
|
|
|
|
|
+ leptos::logging::log!("hello world!");
|
|
|
+
|
|
|
let greet = move |ev: SubmitEvent| {
|
|
|
ev.prevent_default();
|
|
|
spawn_local(async move {
|
|
@@ -39,49 +44,16 @@ pub fn App() -> impl IntoView {
|
|
|
if name.is_empty() {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
let args = serde_wasm_bindgen::to_value(&GreetArgs { name: &name }).unwrap();
|
|
|
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
|
|
let new_msg = invoke("greet", args).await.as_string().unwrap();
|
|
|
- let foogazi = "foobar";
|
|
|
- // invoke(
|
|
|
- // "eval",
|
|
|
- // serde_wasm_bindgen::to_value(&Eval {
|
|
|
- // str: &format!(
|
|
|
- // "console.log(this); this.requestContext = {{ request: \"{foogazi}\" }}"
|
|
|
- // ),
|
|
|
- // })
|
|
|
- // .unwrap(),
|
|
|
- // )
|
|
|
- // .await;
|
|
|
- dbg!(
|
|
|
- invoke(
|
|
|
- "eval",
|
|
|
- serde_wasm_bindgen::to_value(&Eval {
|
|
|
- str: "return { foo: \"bar\"; baz: 4 }"
|
|
|
- })
|
|
|
- .unwrap(),
|
|
|
- )
|
|
|
- .await
|
|
|
- );
|
|
|
set_greet_msg.set(new_msg);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
view! {
|
|
|
+ <Header />
|
|
|
<main class="container">
|
|
|
- <h1>"Welcome to Tauri + Leptos"</h1>
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <a href="https://tauri.app" target="_blank">
|
|
|
- <img src="public/tauri.svg" class="logo tauri" alt="Tauri logo"/>
|
|
|
- </a>
|
|
|
- <a href="https://docs.rs/leptos/" target="_blank">
|
|
|
- <img src="public/leptos.svg" class="logo leptos" alt="Leptos logo"/>
|
|
|
- </a>
|
|
|
- </div>
|
|
|
- <p>"Click on the Tauri and Leptos logos to learn more."</p>
|
|
|
-
|
|
|
<form class="row" on:submit=greet>
|
|
|
<input
|
|
|
id="greet-input"
|
|
@@ -94,3 +66,17 @@ pub fn App() -> impl IntoView {
|
|
|
</main>
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#[component]
|
|
|
+pub fn Header() -> impl IntoView {
|
|
|
+ view! {
|
|
|
+ <header class=header_styles::header>
|
|
|
+ <h1 class=header_styles::title>"rested"</h1>
|
|
|
+
|
|
|
+ <nav class=header_styles::nav>
|
|
|
+ <a href="#">"Home"</a>
|
|
|
+ <a href="#">"Settings"</a>
|
|
|
+ </nav>
|
|
|
+ </header>
|
|
|
+ }
|
|
|
+}
|