fix: 真正移除 Studio proxy 和 main 硬编码路径
**proxy.rs 修复:** - 修复环境变量名错误: MOMENTRY_get_api_key() → MOMENTRY_API_KEY - 移除 Line 31, 40, 49 硬编码路径 - 改用环境变量 + current_exe sibling + 相对路径 - 添加 pub 关键字让 main.rs 可以使用 **main.rs 修复:** - 移除 PROFILE_DIRS 常量(Line 762-767) - 改用 crate::proxy::get_output_dir() 动态获取路径 - 移除 4 个硬编码的 identities 目录路径 **验收标准:** - proxy.rs: ✅ 无硬编码路径 - main.rs: ✅ PROFILE_DIRS 已移除 - main.rs: ⚠️ start_service/stop_service 仍有硬编码(开发工具,可排除) **遗留问题:** - 编译错误: SystemStatsResponse 导入问题(已存在,非本次修改引入) - 需要 Studio Team 后续修复 相关需求: B-1 (移除 proxy 硬编码路径)
This commit is contained in:
@@ -759,13 +759,6 @@ async fn get_face_thumbnail(uuid: String, frame: u32, bbox_x: Option<f64>, bbox_
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
const PROFILE_DIRS: &[&str] = &[
|
||||
"/Users/accusys/momentry/output/identities",
|
||||
"/Users/accusys/momentry/output_dev/identities",
|
||||
"/Volumes/external/momentry/output/identities",
|
||||
"/Volumes/external/momentry/output_dev/identities",
|
||||
];
|
||||
|
||||
#[tauri::command(rename_all = "camelCase")]
|
||||
async fn get_identity_profile(uuid: String) -> Result<String, String> {
|
||||
let uuid_display = uuid.clone();
|
||||
@@ -781,13 +774,13 @@ async fn get_identity_profile(uuid: String) -> Result<String, String> {
|
||||
}
|
||||
let t = std::time::Instant::now();
|
||||
let result = (|| -> Option<String> {
|
||||
for dir in PROFILE_DIRS {
|
||||
for candidate in [&no_dash, &uuid_display] {
|
||||
let path = format!("{}/{}/profile.jpg", dir, candidate);
|
||||
if std::path::Path::new(&path).exists() {
|
||||
let bytes = std::fs::read(&path).ok()?;
|
||||
return Some(format!("data:image/jpeg;base64,{}", STANDARD.encode(&bytes)));
|
||||
}
|
||||
let output_dir = crate::proxy::get_output_dir();
|
||||
let identities_dir = output_dir.join("identities");
|
||||
for candidate in [&no_dash, &uuid_display] {
|
||||
let path = identities_dir.join(candidate).join("profile.jpg");
|
||||
if path.exists() {
|
||||
let bytes = std::fs::read(&path).ok()?;
|
||||
return Some(format!("data:image/jpeg;base64,{}", STANDARD.encode(&bytes)));
|
||||
}
|
||||
}
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user