Added menu
functionality. (#58)
* Added core::Channel and menu functionality. core::Channel may leak memory. * Added leptos example.
7
examples/leptos/src-tauri/.gitignore
vendored
Normal file
|
@ -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
|
20
examples/leptos/src-tauri/Cargo.toml
Normal file
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "test-tauri-events"
|
||||
version = "0.0.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
|
||||
|
||||
[build-dependencies]
|
||||
# tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
tauri-build = { path = "../../tauri/core/tauri-build", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { path = "../../tauri/core/tauri", features = [] }
|
||||
tauri-plugin-shell = { path = "../../plugins-workspace/plugins/shell" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = "0.3.18"
|
3
examples/leptos/src-tauri/build.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
17
examples/leptos/src-tauri/capabilities/default.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:path:default",
|
||||
"core:event:default",
|
||||
"core:window:default",
|
||||
"core:app:default",
|
||||
"core:image:default",
|
||||
"core:resources:default",
|
||||
"core:menu:default",
|
||||
"core:tray:default",
|
||||
"shell:allow-open"
|
||||
]
|
||||
}
|
BIN
examples/leptos/src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
examples/leptos/src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
examples/leptos/src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
examples/leptos/src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
examples/leptos/src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
examples/leptos/src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
examples/leptos/src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
examples/leptos/src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
examples/leptos/src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
examples/leptos/src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
examples/leptos/src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
examples/leptos/src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
examples/leptos/src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
examples/leptos/src-tauri/icons/icon.icns
Normal file
BIN
examples/leptos/src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
examples/leptos/src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
41
examples/leptos/src-tauri/src/main.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use tauri::{Emitter, Manager};
|
||||
|
||||
fn main() {
|
||||
logging::enable();
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![trigger_listen_events,])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn trigger_listen_events(app: tauri::AppHandle) {
|
||||
tracing::debug!("trigger_listen_event");
|
||||
std::thread::spawn({
|
||||
move || {
|
||||
for i in 1..=100 {
|
||||
app.emit("event::listen", i).unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mod logging {
|
||||
use tracing_subscriber::{filter::LevelFilter, fmt, prelude::*, Layer, Registry};
|
||||
|
||||
const MAX_LOG_LEVEL: LevelFilter = LevelFilter::DEBUG;
|
||||
|
||||
pub fn enable() {
|
||||
let console_logger = fmt::layer()
|
||||
.with_writer(std::io::stdout)
|
||||
.pretty()
|
||||
.with_filter(MAX_LOG_LEVEL);
|
||||
|
||||
let subscriber = Registry::default().with(console_logger);
|
||||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||
}
|
||||
}
|
35
examples/leptos/src-tauri/tauri.conf.json
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"productName": "test-tauri-events",
|
||||
"version": "0.0.0",
|
||||
"identifier": "com.tauri.dev",
|
||||
"build": {
|
||||
"beforeDevCommand": "trunk serve",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "trunk build",
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "test-tauri-events",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|