性能优化

This commit is contained in:
zhongluofeng
2026-08-06 10:33:16 +08:00
parent c7578a2e6b
commit e66c53e66d
105 changed files with 7273 additions and 5002 deletions
+10
View File
@@ -8,12 +8,14 @@ use super::task::{DownloadTask, DownloaderSettings};
/// 获取所有任务
#[tauri::command]
#[specta::specta]
pub fn downloader_get_tasks(engine: State<'_, DownloadEngine>) -> Vec<DownloadTask> {
engine.get_tasks()
}
/// 检查 URL 重复性并探测文件信息(添加下载前调用)
#[tauri::command]
#[specta::specta]
pub async fn downloader_check_url(
engine: State<'_, DownloadEngine>,
url: String,
@@ -47,6 +49,7 @@ pub async fn downloader_check_url(
/// 添加下载任务
#[tauri::command]
#[specta::specta]
pub async fn downloader_add_task(
engine: State<'_, DownloadEngine>,
url: String,
@@ -60,18 +63,21 @@ pub async fn downloader_add_task(
/// 暂停任务
#[tauri::command]
#[specta::specta]
pub fn downloader_pause_task(engine: State<'_, DownloadEngine>, id: String) -> Result<(), String> {
engine.pause_task(&id)
}
/// 恢复任务
#[tauri::command]
#[specta::specta]
pub fn downloader_resume_task(engine: State<'_, DownloadEngine>, id: String) -> Result<(), String> {
engine.resume_task(&id)
}
/// 移除任务
#[tauri::command]
#[specta::specta]
pub fn downloader_remove_task(
engine: State<'_, DownloadEngine>,
id: String,
@@ -82,12 +88,14 @@ pub fn downloader_remove_task(
/// 获取设置
#[tauri::command]
#[specta::specta]
pub fn downloader_get_settings(engine: State<'_, DownloadEngine>) -> DownloaderSettings {
engine.get_settings()
}
/// 保存设置
#[tauri::command]
#[specta::specta]
pub fn downloader_save_settings(
engine: State<'_, DownloadEngine>,
settings: DownloaderSettings,
@@ -118,6 +126,7 @@ pub fn downloader_get_extension_info(engine: State<'_, DownloadEngine>) -> serde
/// 用系统资源管理器打开目录
#[tauri::command]
#[specta::specta]
pub fn downloader_open_dir(app: AppHandle, path: String) -> Result<(), String> {
app.opener()
.open_path(path, None::<&str>)
@@ -126,6 +135,7 @@ pub fn downloader_open_dir(app: AppHandle, path: String) -> Result<(), String> {
/// 用系统默认浏览器打开 URL
#[tauri::command]
#[specta::specta]
pub fn downloader_open_url(app: AppHandle, url: String) -> Result<(), String> {
app.opener()
.open_url(url, None::<&str>)