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:
63
skills/tauri/templates/src-tauri/commands/mod.rs
Normal file
63
skills/tauri/templates/src-tauri/commands/mod.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
// Tauri Commands Module
|
||||
// This module contains all the commands exposed to the frontend
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Common result type for commands
|
||||
pub type CommandResult<T> = Result<T, String>;
|
||||
|
||||
/// Example payload structure
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ExamplePayload {
|
||||
pub data: String,
|
||||
pub count: i32,
|
||||
}
|
||||
|
||||
// Basic example command
|
||||
#[tauri::command]
|
||||
pub fn greet(name: &str) -> CommandResult<String> {
|
||||
Ok(format!("Hello, {}! From Rust backend!", name))
|
||||
}
|
||||
|
||||
// Example with structured payload
|
||||
#[tauri::command]
|
||||
pub fn process_data(payload: ExamplePayload) -> CommandResult<String> {
|
||||
Ok(format!("Processed: {} (count: {})", payload.data, payload.count))
|
||||
}
|
||||
|
||||
// Async command example
|
||||
#[tauri::command]
|
||||
pub async fn async_operation(input: String) -> CommandResult<String> {
|
||||
// Simulate async work
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||
Ok(format!("Async result from: {}", input))
|
||||
}
|
||||
|
||||
// Error handling example
|
||||
#[tauri::command]
|
||||
pub fn command_with_error(should_fail: bool) -> CommandResult<String> {
|
||||
if should_fail {
|
||||
Err("This command failed as requested".to_string())
|
||||
} else {
|
||||
Ok("Command succeeded!".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
// Complex command with multiple parameters
|
||||
#[tauri::command]
|
||||
pub fn complex_command(
|
||||
text: String,
|
||||
number: i32,
|
||||
flag: bool,
|
||||
) -> CommandResult<String> {
|
||||
Ok(format!(
|
||||
"Text: {}, Number: {}, Flag: {}",
|
||||
text, number, flag
|
||||
))
|
||||
}
|
||||
|
||||
// Export all commands
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// This function is called on mobile platforms
|
||||
}
|
||||
Reference in New Issue
Block a user