feat: add Mihomo API modules and manager (#2869)
• Introduce new API caller implementations for Mihomo in model and module layers. • Add configuration and API integration files under /src-tauri/src/config/api and /src-tauri/src/model/api. • Implement a singleton MihomoAPICaller with async API call support and integration tests. • Create a new MihomoManager module to refresh and fetch proxies from the API. • Update Cargo.lock and Cargo.toml with additional dependencies (async-trait, env_logger, mockito, tempfile, etc.) related to the Mihomo API support.
This commit is contained in:
committed by
GitHub
Unverified
parent
6e48781687
commit
2cd97c7785
20
src-tauri/src/model/api/common.rs
Normal file
20
src-tauri/src/model/api/common.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use reqwest::Client;
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) struct ApiCaller<'a> {
|
||||
pub(crate) url: &'a str,
|
||||
pub(crate) client: Client,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_api_caller() {
|
||||
let _api_caller = ApiCaller {
|
||||
url: "https://example.com",
|
||||
client: Client::new(),
|
||||
};
|
||||
}
|
||||
}
|
||||
5
src-tauri/src/model/api/mihomo.rs
Normal file
5
src-tauri/src/model/api/mihomo.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
use super::common::ApiCaller;
|
||||
|
||||
pub struct MihomoAPICaller {
|
||||
pub(crate) caller: ApiCaller<'static>,
|
||||
}
|
||||
2
src-tauri/src/model/api/mod.rs
Normal file
2
src-tauri/src/model/api/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod common;
|
||||
pub mod mihomo;
|
||||
@@ -1 +1,2 @@
|
||||
pub mod sysinfo;
|
||||
pub mod api;
|
||||
pub mod sysinfo;
|
||||
|
||||
Reference in New Issue
Block a user