Loading...
Loading...
Compare original and translation side by side
src/
├── app/ # Next.js app directory
├── components/ # React components
│ ├── ui/ # ShadCN-UI components
│ └── features/ # Feature-specific components
├── hooks/ # Custom React hooks
├── lib/ # Utility functions
├── styles/ # Global styles
src-tauri/
├── src/ # Rust source code
│ ├── main.rs # Entry point
│ └── commands/ # Tauri commands
├── Cargo.toml # Rust dependencies
└── tauri.conf.json # Tauri configurationsrc/
├── app/ # Next.js应用目录
├── components/ # React组件
│ ├── ui/ # ShadCN-UI组件
│ └── features/ # 功能特定组件
├── hooks/ # 自定义React Hooks
├── lib/ # 工具函数
├── styles/ # 全局样式
src-tauri/
├── src/ # Rust源代码
│ ├── main.rs # 入口文件
│ └── commands/ # Tauri命令
├── Cargo.toml # Rust依赖配置
└── tauri.conf.json # Tauri配置文件import { invoke } from '@tauri-apps/api/tauri';
// Call Rust commands from frontend
const result = await invoke<string>('my_command', { arg: 'value' });
// Listen to events from Rust
import { listen } from '@tauri-apps/api/event';
await listen('event-name', (event) => {
console.log(event.payload);
});import { invoke } from '@tauri-apps/api/tauri';
// 从前端调用Rust命令
const result = await invoke<string>('my_command', { arg: 'value' });
// 监听来自Rust的事件
import { listen } from '@tauri-apps/api/event';
await listen('event-name', (event) => {
console.log(event.payload);
});#[tauri::command]
fn my_command(arg: String) -> Result<String, String> {
// Implementation
Ok(format!("Received: {}", arg))
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_command])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}#[tauri::command]
fn my_command(arg: String) -> Result<String, String> {
// 实现逻辑
Ok(format!("Received: {}", arg))
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_command])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}use std::fs;
use tauri::api::path::app_data_dir;
#[tauri::command]
fn read_file(path: String) -> Result<String, String> {
fs::read_to_string(&path)
.map_err(|e| e.to_string())
}
#[tauri::command]
fn write_file(path: String, content: String) -> Result<(), String> {
fs::write(&path, content)
.map_err(|e| e.to_string())
}use std::fs;
use tauri::api::path::app_data_dir;
#[tauri::command]
fn read_file(path: String) -> Result<String, String> {
fs::read_to_string(&path)
.map_err(|e| e.to_string())
}
#[tauri::command]
fn write_file(path: String, content: String) -> Result<(), String> {
fs::write(&path, content)
.map_err(|e| e.to_string())
}