-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide simple command-based tauri app
- Loading branch information
Yassen Damyanov
committed
Jul 20, 2021
1 parent
00bf39c
commit b30fc79
Showing
12 changed files
with
211 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,15 @@ | ||
# .gitignore for tauri-events-minimal | ||
|
||
# will have compiled files and executables | ||
/target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# Front-end-specific exclusions | ||
node_modules/ | ||
yarn.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,14 @@ | ||
{ | ||
"name": "tauri-events-minimal", | ||
"version": "0.1.0", | ||
"description": "Minimal Tauri events example", | ||
"main": "index.html", | ||
"repository": "https://github.com/yassen-damyanov/tauri-events-minimal.git", | ||
"author": "Yassen Damyanov <[email protected]>", | ||
"license": "Apache-2.0", | ||
"private": false, | ||
"devDependencies": { | ||
"@tauri-apps/api": "^1.0.0-beta.5", | ||
"@tauri-apps/cli": "^1.0.0-beta.6" | ||
} | ||
} |
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/ | ||
WixTools | ||
|
||
# Exclude the auto-genrated icons for now | ||
/icons/ |
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,24 @@ | ||
[package] | ||
name = "app" | ||
version = "0.1.0" | ||
description = "A Tauri App" | ||
authors = ["you"] | ||
license = "" | ||
repository = "" | ||
default-run = "app" | ||
edition = "2018" | ||
build = "src/build.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[build-dependencies] | ||
tauri-build = { version = "1.0.0-beta.3" } | ||
|
||
[dependencies] | ||
serde_json = "1.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
tauri = { version = "1.0.0-beta.5", features = ["api-all"] } | ||
|
||
[features] | ||
default = [ "custom-protocol" ] | ||
custom-protocol = [ "tauri/custom-protocol" ] |
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 @@ | ||
max_width = 99 | ||
hard_tabs = false | ||
tab_spaces = 3 | ||
newline_style = "Auto" | ||
use_small_heuristics = "Default" | ||
reorder_imports = true | ||
reorder_modules = true | ||
remove_nested_parens = true | ||
edition = "2018" | ||
merge_derives = true | ||
use_try_shorthand = false | ||
use_field_init_shorthand = false | ||
force_explicit_abi = true | ||
imports_granularity = "Crate" |
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,19 @@ | ||
#![cfg_attr( | ||
all(not(debug_assertions), target_os = "windows"), | ||
windows_subsystem = "windows" | ||
)] | ||
|
||
#[tauri::command] | ||
fn say_hello(name: String) -> String { | ||
let response = format!("Hello, {}!", name); | ||
println!("{:?}", response); | ||
response.into() | ||
} | ||
|
||
fn main() { | ||
println!("** Tauri app about to start"); | ||
tauri::Builder::default() | ||
.invoke_handler(tauri::generate_handler![say_hello,]) | ||
.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,68 @@ | ||
{ | ||
"package": { | ||
"productName": "tauri-events-minimal", | ||
"version": "0.1.0" | ||
}, | ||
"build": { | ||
"distDir": "../www", | ||
"devPath": "../www", | ||
"beforeDevCommand": "", | ||
"beforeBuildCommand": "", | ||
"withGlobalTauri": true | ||
}, | ||
"tauri": { | ||
"bundle": { | ||
"active": true, | ||
"targets": "all", | ||
"identifier": "com.tauri.dev", | ||
"icon": [ | ||
"icons/32x32.png", | ||
"icons/128x128.png", | ||
"icons/[email protected]", | ||
"icons/icon.icns", | ||
"icons/icon.ico" | ||
], | ||
"resources": [], | ||
"externalBin": [], | ||
"copyright": "", | ||
"category": "DeveloperTool", | ||
"shortDescription": "", | ||
"longDescription": "", | ||
"deb": { | ||
"depends": [], | ||
"useBootstrapper": false | ||
}, | ||
"macOS": { | ||
"frameworks": [], | ||
"minimumSystemVersion": "", | ||
"useBootstrapper": false, | ||
"exceptionDomain": "", | ||
"signingIdentity": null, | ||
"entitlements": null | ||
}, | ||
"windows": { | ||
"certificateThumbprint": null, | ||
"digestAlgorithm": "sha256", | ||
"timestampUrl": "" | ||
} | ||
}, | ||
"updater": { | ||
"active": false | ||
}, | ||
"allowlist": { | ||
"all": true | ||
}, | ||
"windows": [ | ||
{ | ||
"title": "Tauri Events (Minimal Sample App)", | ||
"width": 800, | ||
"height": 600, | ||
"resizable": true, | ||
"fullscreen": false | ||
} | ||
], | ||
"security": { | ||
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" | ||
} | ||
} | ||
} |
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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Tauri Events (Minimal Example)</title> | ||
<link href="/styles.css" rel="stylesheet" /> | ||
|
||
<script type="text/javascript"> | ||
var Tauri = null; | ||
import('/invoke.js').then(imported => { | ||
Tauri = imported; | ||
}); | ||
|
||
const sayHello = () => { | ||
console.log('sayHello() called') | ||
let name = 'Alice'; | ||
Tauri.invoke_cmd('say_hello', {'name': name}).then(ret => { | ||
console.log(`say_hello('${name}') returned '${ret}'`); | ||
}); | ||
}; | ||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
<h2>Tauri Events (Minimal Example)</h2> | ||
<p>Minimal example for a Tauri events-based application.</p> | ||
<button onclick="sayHello();">Say Hello!</button> | ||
</body> | ||
</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,11 @@ | ||
/** | ||
* Setup the bridge for invoking rust functions. | ||
* (See https://tauri.studio/en/docs/usage/guides/command) | ||
*/ | ||
|
||
// With the Tauri API npm package: | ||
import { invoke } from '/modules/@tauri-apps/api/tauri.js'; | ||
|
||
// With the Tauri global script, enabled when | ||
// `tauri.conf.json > build > withGlobalTauri` is set to true: | ||
export const invoke_cmd = window.__TAURI__.invoke; |
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 @@ | ||
../node_modules |
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 @@ | ||
body { | ||
background-color: #eee; | ||
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; | ||
font-size: 1.4em; | ||
} |