clean c
This commit is contained in:
43
src-tauri/src/lib.rs
Normal file
43
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
mod cleaner;
|
||||
use tauri::State;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[tauri::command]
|
||||
async fn start_fast_scan() -> cleaner::FastScanResult {
|
||||
cleaner::run_fast_scan().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn start_fast_clean(is_simulation: bool) -> Result<String, String> {
|
||||
cleaner::run_fast_clean(is_simulation).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn start_full_disk_scan(state: State<'_, cleaner::DiskState>) -> Result<(), String> {
|
||||
cleaner::run_full_scan("C:\\".to_string(), &state).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_tree_children(path: String, state: State<'_, cleaner::DiskState>) -> Result<Vec<cleaner::FileTreeNode>, String> {
|
||||
Ok(cleaner::get_children(path, &state))
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.manage(cleaner::DiskState {
|
||||
dir_sizes: Mutex::new(HashMap::new()),
|
||||
file_info: Mutex::new(HashMap::new()),
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
start_fast_scan,
|
||||
start_fast_clean,
|
||||
start_full_disk_scan,
|
||||
get_tree_children
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
Reference in New Issue
Block a user