From 6f888295bb76e5f5370d7f1203d5871d06047dff Mon Sep 17 00:00:00 2001
From: imeepos
Date: Tue, 15 Jul 2025 12:59:27 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=B4=A0=E6=9D=90?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=97=B6=E7=9A=84=E6=A8=A1=E7=89=B9=E7=BB=91?=
=?UTF-8?q?=E5=AE=9A=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在 CreateMaterialRequest 中添加 model_id 字段
- 更新 Material 实体添加 new_with_model 方法支持创建时绑定模特
- 修改 MaterialService 和 AsyncMaterialService 支持导入时模特绑定
- 在 MaterialImportDialog 中添加模特选择下拉框
- 支持在导入素材时可选择绑定到特定模特
- 遵循 Tauri 开发规范的组件设计和业务逻辑分层
---
.../services/async_material_service.rs | 8 ++-
.../src/business/services/material_service.rs | 8 +--
.../src-tauri/src/data/models/material.rs | 32 +++++++++++
.../src/components/MaterialImportDialog.tsx | 53 +++++++++++++++++++
apps/desktop/src/types/material.ts | 1 +
5 files changed, 97 insertions(+), 5 deletions(-)
diff --git a/apps/desktop/src-tauri/src/business/services/async_material_service.rs b/apps/desktop/src-tauri/src/business/services/async_material_service.rs
index abe2e7a..f761493 100644
--- a/apps/desktop/src-tauri/src/business/services/async_material_service.rs
+++ b/apps/desktop/src-tauri/src/business/services/async_material_service.rs
@@ -77,6 +77,7 @@ impl AsyncMaterialService {
let file_path_clone = file_path.clone();
let config_clone = config.clone();
let event_bus_clone = Arc::clone(&event_bus);
+ let model_id_clone = request.model_id.clone();
match Self::process_single_file_async(
repository_clone,
@@ -84,6 +85,7 @@ impl AsyncMaterialService {
&file_path_clone,
&config_clone,
event_bus_clone,
+ model_id_clone,
).await {
Ok(Some(material)) => {
info!(
@@ -153,6 +155,7 @@ impl AsyncMaterialService {
file_path: &str,
config: &MaterialProcessingConfig,
event_bus: Arc,
+ model_id: Option,
) -> Result
)}
+
+ {/* 模特绑定选择 */}
+
+
+
({
+ value: model.id,
+ label: model.stage_name || model.name,
+ })),
+ ]}
+ placeholder={loadingModels ? '加载中...' : '选择模特'}
+ disabled={loadingModels}
+ className="w-full"
+ />
+
+ 选择模特后,导入的素材将自动绑定到该模特
+
+
)}
diff --git a/apps/desktop/src/types/material.ts b/apps/desktop/src/types/material.ts
index f6e33fb..1271e2d 100644
--- a/apps/desktop/src/types/material.ts
+++ b/apps/desktop/src/types/material.ts
@@ -96,6 +96,7 @@ export interface CreateMaterialRequest {
file_paths: string[];
auto_process: boolean;
max_segment_duration?: number;
+ model_id?: string; // 可选的模特绑定ID
}
export interface MaterialProcessingConfig {