This commit is contained in:
che
2026-07-25 11:15:39 +05:00
parent 860ba21dd0
commit 0544d41b54
27 changed files with 766 additions and 120 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
"opener:default",
"opener:allow-open-path"
]
}
+35 -1
View File
@@ -55,6 +55,39 @@ async fn sync_contracts(
sync::sync_contracts(&api, app_data_dir).await
}
#[tauri::command]
async fn load_application_file(local_path: String, scan_url: String) -> Result<Vec<u8>, ApiError> {
if !local_path.is_empty() {
match tokio::fs::metadata(&local_path).await {
Ok(metadata) if metadata.len() > 0 => {
return tokio::fs::read(&local_path)
.await
.map_err(|error| ApiError::new("file_error", error.to_string()));
}
Ok(_) | Err(_) => {}
}
}
if scan_url.is_empty() {
return Err(ApiError::new("file_error", "Файл недоступен"));
}
let response = reqwest::Client::new().get(&scan_url).send().await?;
if !response.status().is_success() {
return Err(ApiError::new(
"remote_error",
format!("file download failed with {}", response.status()),
));
}
let bytes = response.bytes().await?;
if bytes.is_empty() {
return Err(ApiError::new("file_error", "Файл пустой"));
}
Ok(bytes.to_vec())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
#[cfg(target_os = "linux")]
@@ -83,7 +116,8 @@ pub fn run() {
auth_set_token,
auth_logout,
auth_status,
sync_contracts
sync_contracts,
load_application_file
])
.run(tauri::generate_context!())
.expect("error while running tauri application");