-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e3f2b00
Showing
36 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/dist/ | ||
/target/ | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/src | ||
/public | ||
/Cargo.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"emmet.includeLanguages": { | ||
"rust": "html" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "tomaru-ui" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[dependencies] | ||
leptos = { version = "0.6", features = ["csr"] } | ||
wasm-bindgen = "0.2" | ||
wasm-bindgen-futures = "0.4" | ||
js-sys = "0.3" | ||
serde = { version = "1", features = ["derive"] } | ||
serde-wasm-bindgen = "0.6" | ||
console_error_panic_hook = "0.1.7" | ||
|
||
[workspace] | ||
members = ["src-tauri"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Tauri + Leptos | ||
|
||
This template should help get you started developing with Tauri and Leptos. | ||
|
||
## Recommended IDE Setup | ||
|
||
[VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[build] | ||
target = "./index.html" | ||
|
||
[watch] | ||
ignore = ["./src-tauri"] | ||
|
||
[serve] | ||
port = 1420 | ||
open = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Tauri + Leptos App</title> | ||
<link data-trunk rel="css" href="styles.css" /> | ||
<link data-trunk rel="copy-dir" href="public" /> | ||
<link data-trunk rel="rust" data-wasm-opt="z" /> | ||
</head> | ||
<body></body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
||
# Generated by Tauri | ||
# will have schema files for capabilities auto-completion | ||
/gen/schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "tomaru" | ||
version = "0.1.0" | ||
description = "A Tauri App" | ||
authors = ["you"] | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
# The `_lib` suffix may seem redundant but it is necessary | ||
# to make the lib name unique and wouldn't conflict with the bin name. | ||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 | ||
name = "tomaru_lib" | ||
crate-type = ["staticlib", "cdylib", "rlib"] | ||
|
||
[build-dependencies] | ||
tauri-build = { version = "2", features = [] } | ||
|
||
[dependencies] | ||
tauri = { version = "2", features = [] } | ||
tauri-plugin-shell = "2" | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
tauri_build::build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "../gen/schemas/desktop-schema.json", | ||
"identifier": "default", | ||
"description": "Capability for the main window", | ||
"windows": ["main"], | ||
"permissions": [ | ||
"core:default", | ||
"shell:allow-open" | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ | ||
#[tauri::command] | ||
fn greet(name: &str) -> String { | ||
format!("Hello, {}! You've been greeted from Rust!", name) | ||
} | ||
|
||
#[cfg_attr(mobile, tauri::mobile_entry_point)] | ||
pub fn run() { | ||
tauri::Builder::default() | ||
.plugin(tauri_plugin_shell::init()) | ||
.invoke_handler(tauri::generate_handler![greet]) | ||
.run(tauri::generate_context!()) | ||
.expect("error while running tauri application"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Prevents additional console window on Windows in release, DO NOT REMOVE!! | ||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | ||
|
||
fn main() { | ||
tomaru_lib::run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"$schema": "https://schema.tauri.app/config/2", | ||
"productName": "tomaru", | ||
"version": "0.1.0", | ||
"identifier": "com.tomaru.app", | ||
"build": { | ||
"beforeDevCommand": "trunk serve", | ||
"devUrl": "http://localhost:1420", | ||
"beforeBuildCommand": "trunk build", | ||
"frontendDist": "../dist" | ||
}, | ||
"app": { | ||
"withGlobalTauri": true, | ||
"windows": [ | ||
{ | ||
"title": "tomaru", | ||
"width": 800, | ||
"height": 600 | ||
} | ||
], | ||
"security": { | ||
"csp": null | ||
} | ||
}, | ||
"bundle": { | ||
"active": true, | ||
"targets": "all", | ||
"icon": [ | ||
"icons/32x32.png", | ||
"icons/128x128.png", | ||
"icons/[email protected]", | ||
"icons/icon.icns", | ||
"icons/icon.ico" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use leptos::leptos_dom::ev::SubmitEvent; | ||
use leptos::*; | ||
use serde::{Deserialize, Serialize}; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])] | ||
async fn invoke(cmd: &str, args: JsValue) -> JsValue; | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct GreetArgs<'a> { | ||
name: &'a str, | ||
} | ||
|
||
#[component] | ||
pub fn App() -> impl IntoView { | ||
let (name, set_name) = create_signal(String::new()); | ||
let (greet_msg, set_greet_msg) = create_signal(String::new()); | ||
|
||
let update_name = move |ev| { | ||
let v = event_target_value(&ev); | ||
set_name.set(v); | ||
}; | ||
|
||
let greet = move |ev: SubmitEvent| { | ||
ev.prevent_default(); | ||
spawn_local(async move { | ||
let name = name.get_untracked(); | ||
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(); | ||
set_greet_msg.set(new_msg); | ||
}); | ||
}; | ||
|
||
view! { | ||
<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" | ||
placeholder="Enter a name..." | ||
on:input=update_name | ||
/> | ||
<button type="submit">"Greet"</button> | ||
</form> | ||
<p>{ move || greet_msg.get() }</p> | ||
</main> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mod app; | ||
|
||
use app::*; | ||
use leptos::*; | ||
|
||
fn main() { | ||
console_error_panic_hook::set_once(); | ||
mount_to_body(|| { | ||
view! { | ||
<App/> | ||
} | ||
}) | ||
} |
Oops, something went wrong.