fix download bug
This commit is contained in:
@@ -26,6 +26,7 @@ pub struct EssentialsRepo {
|
|||||||
pub struct InstallTask {
|
pub struct InstallTask {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub version: Option<String>,
|
pub version: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
pub use_manifest: bool,
|
pub use_manifest: bool,
|
||||||
pub manifest_url: Option<String>,
|
pub manifest_url: Option<String>,
|
||||||
}
|
}
|
||||||
@@ -168,13 +169,10 @@ async fn get_updates(app: AppHandle) -> Vec<Software> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn install_software(
|
async fn install_software(
|
||||||
id: String,
|
task: InstallTask,
|
||||||
version: Option<String>,
|
|
||||||
use_manifest: bool,
|
|
||||||
manifest_url: Option<String>,
|
|
||||||
state: State<'_, AppState>
|
state: State<'_, AppState>
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
state.install_tx.send(InstallTask { id, version, use_manifest, manifest_url }).await.map_err(|e| e.to_string())
|
state.install_tx.send(task).await.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -345,6 +343,11 @@ pub fn run() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
emit_log(&handle, &log_id, "Result", &format!("Execution finished: {}", status_result), if status_result == "success" { "success" } else { "error" });
|
emit_log(&handle, &log_id, "Result", &format!("Execution finished: {}", status_result), if status_result == "success" { "success" } else { "error" });
|
||||||
|
|
||||||
|
// 3. 清理临时清单文件
|
||||||
|
if let Some(path) = temp_manifest_path {
|
||||||
|
let _ = fs::remove_file(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -194,12 +194,19 @@ export const useSoftwareStore = defineStore('software', {
|
|||||||
const software = this.findSoftware(id)
|
const software = this.findSoftware(id)
|
||||||
if (software) {
|
if (software) {
|
||||||
software.status = 'pending';
|
software.status = 'pending';
|
||||||
await invoke('install_software', {
|
try {
|
||||||
id,
|
await invoke('install_software', {
|
||||||
version: software.version,
|
task: {
|
||||||
use_manifest: software.use_manifest,
|
id,
|
||||||
manifest_url: software.manifest_url
|
version: software.recommended_version || software.version,
|
||||||
})
|
use_manifest: software.use_manifest || false,
|
||||||
|
manifest_url: software.manifest_url || null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Invoke install failed:', err);
|
||||||
|
software.status = 'error';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findSoftware(id: string) {
|
findSoftware(id: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user