Skip to content

Commit

Permalink
feat: hello-tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
katopz committed Jan 26, 2025
1 parent 882ae75 commit 750e3c6
Show file tree
Hide file tree
Showing 35 changed files with 522 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/r1/hello-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
/target/
/Cargo.lock
3 changes: 3 additions & 0 deletions examples/r1/hello-tauri/.taurignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/src
/assets
/Cargo.toml
7 changes: 7 additions & 0 deletions examples/r1/hello-tauri/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer",
"DioxusLabs.dioxus"
]
}
30 changes: 30 additions & 0 deletions examples/r1/hello-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "hello-tauri-ui"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { version = "0.6", features = ["web"] }
dioxus-logger = "0.6"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = "0.3"
js-sys = "0.3"
serde = { version = "1", features = ["derive"] }
serde-wasm-bindgen = "0.6"

[workspace]
members = ["src-tauri"]

[profile]

[profile.wasm-dev]
inherits = "dev"
opt-level = 1

[profile.server-dev]
inherits = "dev"

[profile.android-dev]
inherits = "dev"
12 changes: 12 additions & 0 deletions examples/r1/hello-tauri/Dioxus.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[application]
name = "hello-tauri-ui"
default_platform = "web"
out_dir = "dist"
asset_dir = "assets"

[web.app]
title = "Tauri + Dioxus App"

[web.watcher]
reload_html = true
watch_path = ["src", "assets"]
31 changes: 31 additions & 0 deletions examples/r1/hello-tauri/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Broken

This is an example from official but it's stuck at build page forever.

```
"build": {
"beforeDevCommand": "dx serve --port 1420",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "dx build --release",
"frontendDist": "../dist"
},
```

## Workaround

Delete `beforeDevCommand` and run `dx serve --port 1420` ourself

```
"build": {
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "dx build --release",
"frontendDist": "../dist"
},
```

## Dev

```
dx serve --port 1420
cargo tauri dev
```
Binary file added examples/r1/hello-tauri/assets/dioxus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions examples/r1/hello-tauri/assets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
.logo.dioxus:hover {
filter: drop-shadow(0 0 2em #2076a8);
}
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color: #0f0f0f;
background-color: #f6f6f6;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}

.logo.tauri:hover {
filter: drop-shadow(0 0 2em #24c8db);
}

.row {
display: flex;
justify-content: center;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}

a:hover {
color: #535bf2;
}

h1 {
text-align: center;
}

input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

button {
cursor: pointer;
}

button:hover {
border-color: #396cd8;
}
button:active {
border-color: #396cd8;
background-color: #e8e8e8;
}

input,
button {
outline: none;
}

#greet-input {
margin-right: 5px;
}

@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}

a:hover {
color: #24c8db;
}

input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
button:active {
background-color: #0f0f0f69;
}
}
6 changes: 6 additions & 0 deletions examples/r1/hello-tauri/assets/tauri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/r1/hello-tauri/src-tauri/.gitignore
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
29 changes: 29 additions & 0 deletions examples/r1/hello-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "hello-tauri"
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 = "hello_tauri_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[build-dependencies]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
reqwest = "0.12.12"
anyhow = "1.0.95"

[dev-dependencies]
tokio = { version = "1.43.0", features = ["full"] }
3 changes: 3 additions & 0 deletions examples/r1/hello-tauri/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
10 changes: 10 additions & 0 deletions examples/r1/hello-tauri/src-tauri/capabilities/default.json
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",
"opener:default"
]
}
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 added examples/r1/hello-tauri/src-tauri/icons/32x32.png
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 added examples/r1/hello-tauri/src-tauri/icons/icon.icns
Binary file not shown.
Binary file added examples/r1/hello-tauri/src-tauri/icons/icon.ico
Binary file not shown.
Binary file added examples/r1/hello-tauri/src-tauri/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions examples/r1/hello-tauri/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pub mod ray;

use tauri::{
menu::{Menu, MenuItem},
tray::TrayIconBuilder,
};

#[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_opener::init())
.setup(|app| {
let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&quit_i])?;

let tray = TrayIconBuilder::new()
.icon(app.default_window_icon().unwrap().clone())
.menu(&menu)
.show_menu_on_left_click(true)
.build(app)?;

tray.set_title(Some("Hello World"))
.expect("set_title call failed");

Ok(())
})
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
6 changes: 6 additions & 0 deletions examples/r1/hello-tauri/src-tauri/src/main.rs
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() {
hello_tauri_lib::run()
}
Loading

0 comments on commit 750e3c6

Please sign in to comment.