diff --git a/apps/desktop/src-tauri/src/presentation/commands/veo3_actor_define_commands.rs b/apps/desktop/src-tauri/src/presentation/commands/veo3_actor_define_commands.rs index 6a9b10c..eb44dc2 100644 --- a/apps/desktop/src-tauri/src/presentation/commands/veo3_actor_define_commands.rs +++ b/apps/desktop/src-tauri/src/presentation/commands/veo3_actor_define_commands.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use chrono; use veo3_scene_writer::Veo3ActorDefine; -use crate::presentation::commands::tolerant_json_commands::{ParseJsonRequest, JsonParserState}; +use crate::infrastructure::tolerant_json_parser::TolerantJsonParser; /// VEO3 角色定义响应结构 #[derive(Debug, Serialize, Deserialize)] @@ -202,7 +202,6 @@ pub struct CreateActorFileResponse { pub async fn veo3_actor_define_create_actor_file( request: CreateActorFileRequest, session_manager: State<'_, Veo3ActorDefineSessionManager>, - json_parser_state: State<'_, JsonParserState>, ) -> Result { // 获取最近一次助手回复 let last_assistant_message = { @@ -233,16 +232,20 @@ pub async fn veo3_actor_define_create_actor_file( }; // 使用容错JSON解析器提取JSON - let parse_request = ParseJsonRequest { - text: assistant_message, - config: None, + let mut parser = match TolerantJsonParser::new(None) { + Ok(p) => p, + Err(e) => { + return Ok(CreateActorFileResponse { + success: false, + file_path: None, + extracted_json: None, + error: Some(format!("创建JSON解析器失败: {}", e)), + }); + } }; - let parse_response = match crate::presentation::commands::tolerant_json_commands::parse_json_tolerant( - parse_request, - json_parser_state, - ).await { - Ok(response) => response, + let json_data = match parser.parse(&assistant_message) { + Ok((data, _statistics)) => data, Err(e) => { return Ok(CreateActorFileResponse { success: false, @@ -253,17 +256,6 @@ pub async fn veo3_actor_define_create_actor_file( } }; - if !parse_response.success || parse_response.data.is_none() { - return Ok(CreateActorFileResponse { - success: false, - file_path: None, - extracted_json: None, - error: Some(parse_response.error.unwrap_or_else(|| "JSON解析失败".to_string())), - }); - } - - let json_data = parse_response.data.unwrap(); - // 生成文件名 let file_name = request.file_name.unwrap_or_else(|| { let timestamp = chrono::Utc::now().format("%Y%m%d_%H%M%S");