From 578cf0a721ee5cc2160ac4d6fae5d5c23c8aae84 Mon Sep 17 00:00:00 2001 From: CeerDecy <1748788674@qq.com> Date: Fri, 26 Dec 2025 14:48:20 +0800 Subject: [PATCH] fix: windows build bugs --- auto-engine-core/Cargo.toml | 2 +- auto-engine-core/src/node/ocr/runner.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/auto-engine-core/Cargo.toml b/auto-engine-core/Cargo.toml index e33ae64..5b7b8cd 100644 --- a/auto-engine-core/Cargo.toml +++ b/auto-engine-core/Cargo.toml @@ -9,7 +9,7 @@ serde_json = "1.0" serde_yaml = "0.9.34" serde = { version = "1.0", features = ["derive"] } log = "0.4" -opencv = { version = "0", features = ["clang-runtime"] } +opencv = { version = "0", default-features = false, features = ["clang-runtime", "imgproc", "imgcodecs"] } tauri = { version = "2.9.4", features = [] } regex = "1.11.2" futures = "0.3" diff --git a/auto-engine-core/src/node/ocr/runner.rs b/auto-engine-core/src/node/ocr/runner.rs index 15c083b..c14d3ec 100644 --- a/auto-engine-core/src/node/ocr/runner.rs +++ b/auto-engine-core/src/node/ocr/runner.rs @@ -44,18 +44,16 @@ impl NodeRunner for OcrRunner { ctx: &Context, param: Self::ParamType, ) -> Result>, String> { - let handle = ctx.app_handle.clone().unwrap(); + let mut resource_path_prefix = ctx.resource_path().to_string_lossy().replace(r"\\?\", "").to_string(); - let resource_path = if ctx.resource_path().to_string_lossy().to_string() != "" { - format!("{}/",ctx.resource_path().to_string_lossy().to_string()) - } else { - String::new() - }; + if resource_path_prefix != "" { + resource_path_prefix = format!("{}/", resource_path_prefix); + } let ocr = OAROCRBuilder::new( - format!("{}{}",resource_path,"ocr/pp-ocrv5_mobile_det.onnx").as_str(), - format!("{}{}",resource_path,"ocr/pp-ocrv5_mobile_rec.onnx").as_str(), - format!("{}{}",resource_path,"ocr/ppocrv5_dict.txt").as_str(), + format!("{}{}", resource_path_prefix, "ocr/pp-ocrv5_mobile_det.onnx").as_str(), + format!("{}{}", resource_path_prefix, "ocr/pp-ocrv5_mobile_rec.onnx").as_str(), + format!("{}{}", resource_path_prefix, "ocr/ppocrv5_dict.txt").as_str(), ) .build() .map_err(|e| {