Add Tauri framework development skill
Created comprehensive Tauri skill for building desktop and mobile applications with Rust backend and web frontend. Skill Content: - Complete Tauri 2.0 framework coverage - Cross-platform development (Windows, macOS, Linux, iOS, Android) - IPC communication patterns (commands, events, bridges) - Security best practices (capabilities, permissions, CSP) - Native API integration (system tray, notifications, file system) - Build and distribution guidance (code signing, auto-updater) Files Created: - skill.md - Main skill with 6 slash commands - templates/ - tauri.conf.json - Config template with all options - capabilities/default.json - Basic permissions - capabilities/fs-full.json - File system access - capabilities/network.json - Network permissions - src-tauri/commands/mod.rs - Rust command templates - src-tauri/events.rs - Event emission examples - examples/ - command-invoking.txt - Frontend command patterns - event-listening.txt - Event handling patterns - plugin-usage.txt - 10+ plugin examples (fs, http, dialog, etc.) - mobile-setup.txt - iOS/Android development guide Slash Commands: - /tauri-init - Initialize new Tauri project - /tauri-add-plugin - Add Tauri plugin - /tauri-build - Build for specific platform - /tauri-capability - Create permission capability - /tauri-ipc - Design IPC interface - /tauri-native - Add native feature Integration: - Uses rust-patterns for backend code quality - Integrates with react-dev, vue, svelte for frontend - Leverages architecture skill for system design - Uses test-driven-development for testing Credits: - Proper attribution to Tauri Team and The Commons Conservancy - Links to official documentation and community resources - Credits core dependencies: WRY, TAO, Tauri CLI Planned via /brainstorm with comprehensive Ralph-validated design. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
70
skills/tauri/templates/src-tauri/events.rs
Normal file
70
skills/tauri/templates/src-tauri/events.rs
Normal file
@@ -0,0 +1,70 @@
|
||||
// Tauri Events Module
|
||||
// This module demonstrates event emission from Rust to the frontend
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::{Emitter, EmitterExt};
|
||||
|
||||
/// Example event payload
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ProgressEvent {
|
||||
pub current: u32,
|
||||
pub total: u32,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
/// Emit a progress event
|
||||
pub fn emit_progress(app: &tauri::AppHandle, current: u32, total: u32, message: &str) -> tauri::Result<()> {
|
||||
app.emit("progress", ProgressEvent {
|
||||
current,
|
||||
total,
|
||||
message: message.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Emit a data update event
|
||||
pub fn emit_data_update(app: &tauri::AppHandle, data: &str) -> tauri::Result<()> {
|
||||
#[derive(Serialize)]
|
||||
struct DataUpdate {
|
||||
data: String,
|
||||
timestamp: u64,
|
||||
}
|
||||
|
||||
app.emit("data-update", DataUpdate {
|
||||
data: data.to_string(),
|
||||
timestamp: std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Emit an error event
|
||||
pub fn emit_error(app: &tauri::AppHandle, error: &str) -> tauri::Result<()> {
|
||||
#[derive(Serialize)]
|
||||
struct ErrorEvent {
|
||||
error: String,
|
||||
timestamp: u64,
|
||||
}
|
||||
|
||||
app.emit("error", ErrorEvent {
|
||||
error: error.to_string(),
|
||||
timestamp: std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Emit a notification event
|
||||
pub fn emit_notification(app: &tauri::AppHandle, title: &str, body: &str) -> tauri::Result<()> {
|
||||
#[derive(Serialize)]
|
||||
struct NotificationEvent {
|
||||
title: String,
|
||||
body: String,
|
||||
}
|
||||
|
||||
app.emit("notification", NotificationEvent {
|
||||
title: title.to_string(),
|
||||
body: body.to_string(),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user