From 9da90f38ccc46597e1a659fcac83564207aa683b Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Wed, 18 Feb 2026 18:30:53 +0800 Subject: [PATCH] feat(desktop): square file cards and context-menu file actions --- desktop-client/src-tauri/src/lib.rs | 41 +++- desktop-client/src/App.vue | 331 ++++++++++++++-------------- 2 files changed, 210 insertions(+), 162 deletions(-) diff --git a/desktop-client/src-tauri/src/lib.rs b/desktop-client/src-tauri/src/lib.rs index 70fac0f..7c53a39 100644 --- a/desktop-client/src-tauri/src/lib.rs +++ b/desktop-client/src-tauri/src/lib.rs @@ -413,6 +413,44 @@ async fn api_delete_share( .await } +#[tauri::command] +async fn api_create_direct_link( + state: tauri::State<'_, ApiState>, + base_url: String, + file_path: String, + file_name: Option, + expiry_days: Option, +) -> Result { + let mut body = Map::new(); + body.insert("file_path".to_string(), Value::String(file_path)); + + if let Some(name) = file_name { + if !name.trim().is_empty() { + body.insert("file_name".to_string(), Value::String(name.trim().to_string())); + } + } + + if let Some(days) = expiry_days { + if days > 0 { + body.insert("expiry_days".to_string(), Value::Number(days.into())); + } else { + body.insert("expiry_days".to_string(), Value::Null); + } + } else { + body.insert("expiry_days".to_string(), Value::Null); + } + + request_with_optional_csrf( + &state.client, + Method::POST, + &base_url, + "/api/direct-link/create", + Some(Value::Object(body)), + true, + ) + .await +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { let client = reqwest::Client::builder() @@ -436,7 +474,8 @@ pub fn run() { api_get_download_url, api_get_my_shares, api_create_share, - api_delete_share + api_delete_share, + api_create_direct_link ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/desktop-client/src/App.vue b/desktop-client/src/App.vue index cadffad..9aba14b 100644 --- a/desktop-client/src/App.vue +++ b/desktop-client/src/App.vue @@ -1,5 +1,5 @@