mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 15:33:44 +08:00
- Renamed `cmds` module to `cmd` for better naming consistency - Reorganized command modules into separate files under src/cmd/ - Updated all imports and references to use the new module name - Fixed missing dependency in webdav.rs to reference core::backup - Updated tray module to use new cmd namespace - Improved uwp.rs module structure using platform-specific implementations - Removed unnecessary imports from various command files
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
use crate::{
|
|
core,
|
|
config::*,
|
|
feat,
|
|
wrap_err,
|
|
};
|
|
use super::CmdResult;
|
|
use reqwest_dav::list_cmd::ListFile;
|
|
|
|
/// 保存 WebDAV 配置
|
|
#[tauri::command]
|
|
pub async fn save_webdav_config(url: String, username: String, password: String) -> CmdResult<()> {
|
|
let patch = IVerge {
|
|
webdav_url: Some(url),
|
|
webdav_username: Some(username),
|
|
webdav_password: Some(password),
|
|
..IVerge::default()
|
|
};
|
|
Config::verge().draft().patch_config(patch.clone());
|
|
Config::verge().apply();
|
|
Config::verge()
|
|
.data()
|
|
.save_file()
|
|
.map_err(|err| err.to_string())?;
|
|
core::backup::WebDavClient::global().reset();
|
|
Ok(())
|
|
}
|
|
|
|
/// 创建 WebDAV 备份并上传
|
|
#[tauri::command]
|
|
pub async fn create_webdav_backup() -> CmdResult<()> {
|
|
wrap_err!(feat::create_backup_and_upload_webdav().await)
|
|
}
|
|
|
|
/// 列出 WebDAV 上的备份文件
|
|
#[tauri::command]
|
|
pub async fn list_webdav_backup() -> CmdResult<Vec<ListFile>> {
|
|
wrap_err!(feat::list_wevdav_backup().await)
|
|
}
|
|
|
|
/// 删除 WebDAV 上的备份文件
|
|
#[tauri::command]
|
|
pub async fn delete_webdav_backup(filename: String) -> CmdResult<()> {
|
|
wrap_err!(feat::delete_webdav_backup(filename).await)
|
|
}
|
|
|
|
/// 从 WebDAV 恢复备份文件
|
|
#[tauri::command]
|
|
pub async fn restore_webdav_backup(filename: String) -> CmdResult<()> {
|
|
wrap_err!(feat::restore_webdav_backup(filename).await)
|
|
}
|