diff --git a/apps/desktop/src-tauri/src/presentation/commands/material_commands.rs b/apps/desktop/src-tauri/src/presentation/commands/material_commands.rs index f47a4c5..48cc3c3 100644 --- a/apps/desktop/src-tauri/src/presentation/commands/material_commands.rs +++ b/apps/desktop/src-tauri/src/presentation/commands/material_commands.rs @@ -137,6 +137,7 @@ async fn import_materials_with_tauri_events( &request.project_id, file_path, &config, + request.model_id.clone(), app_handle.clone(), ).await { Ok(Some(material)) => { @@ -197,6 +198,7 @@ async fn process_single_file_with_full_logic( project_id: &str, file_path: &str, config: &MaterialProcessingConfig, + model_id: Option, app_handle: tauri::AppHandle, ) -> Result, anyhow::Error> { use anyhow::anyhow; @@ -244,14 +246,18 @@ async fn process_single_file_with_full_logic( // 确定素材类型 let material_type = MaterialType::from_extension(extension); - // 创建素材对象 - let mut material = Material::new( + // 添加调试日志 + println!("Creating material with model_id: {:?}", model_id); + + // 创建素材对象(带模特绑定) + let mut material = Material::new_with_model( project_id.to_string(), file_name.clone(), file_path.to_string(), file_size, md5_hash, material_type.clone(), + model_id, ); // 保存到数据库 diff --git a/apps/desktop/src/components/MaterialImportDialog.tsx b/apps/desktop/src/components/MaterialImportDialog.tsx index 60ea0d5..2f812f9 100644 --- a/apps/desktop/src/components/MaterialImportDialog.tsx +++ b/apps/desktop/src/components/MaterialImportDialog.tsx @@ -210,7 +210,8 @@ export const MaterialImportDialog: React.FC = ({ model_id: selectedModelId || undefined, }; - console.log('开始异步导入:', request); + console.log('前端准备导入,选择的模特ID:', selectedModelId); + console.log('前端导入请求:', request); // 使用异步导入,进度更新和完成状态完全通过事件监听器处理 await importMaterialsAsync(request); diff --git a/apps/desktop/src/store/materialStore.ts b/apps/desktop/src/store/materialStore.ts index ba06aca..dcf285e 100644 --- a/apps/desktop/src/store/materialStore.ts +++ b/apps/desktop/src/store/materialStore.ts @@ -139,6 +139,9 @@ export const useMaterialStore = create((set, get) => ({ // 异步导入素材(新版本,支持实时进度) importMaterialsAsync: async (request: CreateMaterialRequest) => { + console.log('Store层接收到导入请求:', request); + console.log('Store层model_id:', request.model_id); + set({ isImporting: true, error: null, importProgress: { current_file: '', processed_count: 0, @@ -148,6 +151,7 @@ export const useMaterialStore = create((set, get) => ({ }}); try { + console.log('Store层调用Tauri命令,参数:', { request }); const result = await invoke('import_materials_async', { request }); // 更新素材列表