feat(desktop): square file cards and context-menu file actions
This commit is contained in:
@@ -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<String>,
|
||||
expiry_days: Option<i32>,
|
||||
) -> Result<BridgeResponse, String> {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user