fix: 重构的通用Python执行器
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
# Python Executor with Progress Support
|
||||
# 🚀 通用Python执行器进度支持系统
|
||||
|
||||
通用的Python执行器,支持实时进度回调和JSON-RPC通信。
|
||||
一个完全重构的通用Python执行器,支持实时进度回调、JSON-RPC通信和简化的命令创建。
|
||||
|
||||
## ✨ 新特性
|
||||
|
||||
- 🎯 **通用进度支持**:一次实现,到处使用
|
||||
- 🔧 **简化的API**:多种便利函数和宏
|
||||
- 📊 **实时进度更新**:支持Tauri事件和自定义回调
|
||||
- 🛠️ **命令构建器**:简化Python命令构造
|
||||
- 📝 **丰富的示例**:涵盖各种使用场景
|
||||
|
||||
## 功能特性
|
||||
|
||||
@@ -13,7 +21,48 @@
|
||||
- ✅ 超时处理
|
||||
- ✅ 错误处理
|
||||
|
||||
## 使用方法
|
||||
## 🎯 核心API
|
||||
|
||||
### 1. 通用进度执行函数
|
||||
|
||||
```rust
|
||||
// 最通用的函数 - 推荐使用
|
||||
execute_python_action_with_progress(
|
||||
app: AppHandle,
|
||||
module: &str, // Python模块路径
|
||||
action: &str, // 要执行的动作
|
||||
params: &[(&str, &str)], // 参数键值对
|
||||
event_name: &str, // 前端事件名称
|
||||
config: Option<PythonExecutorConfig>
|
||||
) -> Result<String, String>
|
||||
```
|
||||
|
||||
### 2. 便利函数
|
||||
|
||||
```rust
|
||||
// Tauri事件进度(推荐用于前端集成)
|
||||
execute_python_with_events(app, &args, config, "event-name")
|
||||
|
||||
// 函数回调进度(用于自定义处理)
|
||||
execute_python_with_callback(app, &args, config, callback)
|
||||
|
||||
// 基本执行(无进度)
|
||||
execute_python_command(app, &args, config)
|
||||
```
|
||||
|
||||
### 3. 宏支持
|
||||
|
||||
```rust
|
||||
// 简单命令宏
|
||||
python_action_command! {
|
||||
name: my_simple_command,
|
||||
module: "python_core.my_module",
|
||||
action: "my_action",
|
||||
event: "my-progress-event"
|
||||
}
|
||||
```
|
||||
|
||||
## 📋 使用方法
|
||||
|
||||
### 1. 基本用法(无进度)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user