fix: 修复素材导入时model_id为空的问题并添加调试日志
- 修复异步导入函数process_single_file_with_full_logic未使用model_id参数的问题 - 更新函数签名以正确传递model_id参数 - 在素材创建时使用Material::new_with_model而不是Material::new - 在前端、Store层、后端各个环节添加详细的调试日志 - 确保model_id在整个导入流程中正确传递和使用 - 解决素材导入时选择模特但数据库中model_id为null的问题
This commit is contained in:
parent
7e9190dd02
commit
cc46115a26
|
|
@ -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<String>,
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<Option<Material>, 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,
|
||||
);
|
||||
|
||||
// 保存到数据库
|
||||
|
|
|
|||
|
|
@ -210,7 +210,8 @@ export const MaterialImportDialog: React.FC<MaterialImportDialogProps> = ({
|
|||
model_id: selectedModelId || undefined,
|
||||
};
|
||||
|
||||
console.log('开始异步导入:', request);
|
||||
console.log('前端准备导入,选择的模特ID:', selectedModelId);
|
||||
console.log('前端导入请求:', request);
|
||||
|
||||
// 使用异步导入,进度更新和完成状态完全通过事件监听器处理
|
||||
await importMaterialsAsync(request);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,9 @@ export const useMaterialStore = create<MaterialState>((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<MaterialState>((set, get) => ({
|
|||
}});
|
||||
|
||||
try {
|
||||
console.log('Store层调用Tauri命令,参数:', { request });
|
||||
const result = await invoke<MaterialImportResult>('import_materials_async', { request });
|
||||
|
||||
// 更新素材列表
|
||||
|
|
|
|||
Loading…
Reference in New Issue