一键导入
tauri-command
Generate a new Tauri command with Rust handler and TypeScript bindings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate a new Tauri command with Rust handler and TypeScript bindings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | tauri-command |
| description | Generate a new Tauri command with Rust handler and TypeScript bindings |
Generates a complete Tauri command with Rust implementation and TypeScript wrapper.
get_device_info)Location depends on functionality:
src-tauri/src/crypto/mod.rssrc-tauri/src/network/mod.rssrc-tauri/src/lib.rs#[tauri::command]
pub async fn command_name(
param1: String,
param2: Option<i32>,
state: State<'_, AppState>,
) -> Result<ReturnType, String> {
// Implementation
Ok(result)
}
In src-tauri/src/lib.rs, add to invoke_handler! macro:
.invoke_handler(tauri::generate_handler![
// ... existing commands
command_name,
])
Create or update file in src/lib/:
import { invoke } from '@tauri-apps/api/core';
export interface CommandParams {
param1: string;
param2?: number;
}
export interface ReturnType {
// ...
}
export async function commandName(params: CommandParams): Promise<ReturnType> {
return invoke<ReturnType>('command_name', params);
}
get_device_fingerprint{ fingerprint: string, deviceName: string }// In src-tauri/src/crypto/mod.rs
#[tauri::command]
pub async fn get_device_fingerprint(
state: State<'_, AppState>,
) -> Result<DeviceFingerprintResult, String> {
let device = state.device.read().await;
Ok(DeviceFingerprintResult {
fingerprint: device.fingerprint.clone(),
device_name: device.name.clone(),
})
}
#[derive(Serialize)]
pub struct DeviceFingerprintResult {
fingerprint: String,
device_name: String,
}
// In src/lib/crypto/device.ts
import { invoke } from '@tauri-apps/api/core';
export interface DeviceFingerprint {
fingerprint: string;
deviceName: string;
}
export async function getDeviceFingerprint(): Promise<DeviceFingerprint> {
return invoke<DeviceFingerprint>('get_device_fingerprint');
}
| Rust | TypeScript |
|---|---|
| String | string |
| i32, i64 | number |
| f32, f64 | number |
| bool | boolean |
| Vec | T[] |
| Option | T | null |
| HashMap<K, V> | Record<K, V> |
Rust commands return Result<T, String>:
.map_err(|e| e.to_string())?
TypeScript catches invoke errors:
try {
const result = await invoke('command_name', params);
} catch (error) {
console.error('Command failed:', error);
}
State<'_, AppState> parameterGenerate a new React component with Mantine styling
Update documentation after implementing features or making changes
Run a quick architecture review via architect-reviewer agent
Generate mobile-specific React components with platform detection and safe areas
Run a quick security audit on recent changes or specific files
Generate a test file for a component, hook, or utility