From e2a7c6d9e2e98174808774508c7e4a3ae81f89be Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Jul 2025 22:51:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E6=9E=84=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E7=94=A8Python=E6=89=A7=E8=A1=8C=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/python_executor_progress.md | 55 +++++++++++++++++++++++++++-- src/components/AIVideoGenerator.tsx | 23 ------------ src/pages/AIVideoPage.tsx | 11 ------ src/services/templateService.ts | 2 +- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/docs/python_executor_progress.md b/docs/python_executor_progress.md index f849431..98dd7df 100644 --- a/docs/python_executor_progress.md +++ b/docs/python_executor_progress.md @@ -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 +) -> Result +``` + +### 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. 基本用法(无进度) diff --git a/src/components/AIVideoGenerator.tsx b/src/components/AIVideoGenerator.tsx index f955196..e00c42e 100644 --- a/src/components/AIVideoGenerator.tsx +++ b/src/components/AIVideoGenerator.tsx @@ -184,29 +184,6 @@ const AIVideoGenerator: React.FC = ({ className = '' }) = {isProcessing ? '生成中...' : '开始生成'} - - {/* Jobs List */} -
-
-

生成任务

- {jobs.length > 0 && ( - - )} -
- - -
- {/* Video Preview Modal */} {

使用 AI 技术将图片转换为动态视频

- -
- - -
diff --git a/src/services/templateService.ts b/src/services/templateService.ts index 54bd3a9..a17ea82 100644 --- a/src/services/templateService.ts +++ b/src/services/templateService.ts @@ -1,4 +1,4 @@ -import { invoke } from '@tauri-apps/api/tauri' +import { invoke } from '@tauri-apps/api/core' export interface TemplateInfo { id: string