refactor: clean up unused backend code

This commit is contained in:
Tunglies
2026-08-15 00:07:48 +08:00
parent 22947632c0
commit 49f638414b
4 changed files with 2 additions and 24 deletions
-1
View File
@@ -350,7 +350,6 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult<ValidationO
}
/// 根据profile name修改profiles
#[tauri::command]
pub async fn patch_profiles_config_by_profile_index(profile_index: String) -> CmdResult<ValidationOutcome> {
logging!(info, Type::Cmd, "切换配置到: {}", profile_index);
+1 -5
View File
@@ -10,8 +10,6 @@ use tauri_plugin_mihomo::models::WsConnectionId;
/// 托盘速率流异常后的重连间隔。
const TRAY_SPEED_RETRY_DELAY: Duration = Duration::from_secs(1);
/// 托盘速率流运行时的空闲轮询间隔。
const TRAY_SPEED_IDLE_POLL_INTERVAL: Duration = Duration::from_millis(200);
/// 托盘速率流在此时间内收不到有效数据时,触发重连并降级到 0/0。
const TRAY_SPEED_STALE_TIMEOUT: Duration = Duration::from_secs(5);
@@ -88,9 +86,7 @@ impl TraySpeedController {
loop {
let next_state = speed_stream
.next_event(TRAY_SPEED_IDLE_POLL_INTERVAL, TRAY_SPEED_STALE_TIMEOUT, || {
handle::Handle::global().is_exiting()
})
.next_event(TRAY_SPEED_STALE_TIMEOUT, || handle::Handle::global().is_exiting())
.await;
match next_state {
-11
View File
@@ -10,17 +10,6 @@ macro_rules! revise {
};
}
// if key not exists then append value
#[allow(unused_macros)]
macro_rules! append {
($map: expr, $key: expr, $val: expr) => {
let ret_key = Value::String($key.into());
if !$map.contains_key(&ret_key) {
$map.insert(ret_key, Value::from($val));
}
};
}
pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
let tun_key = Value::from("tun");
let tun_val = config.get(&tun_key);
+1 -7
View File
@@ -96,15 +96,9 @@ impl<T> MihomoWsEventStream<T> {
/// 等待下一次可用事件或结束状态。
///
/// # Arguments
/// * `idle_poll_interval` - 空闲检查间隔
/// * `stale_timeout` - 无有效事件超时时间
/// * `should_exit` - 上层退出判定函数
pub async fn next_event<F>(
&mut self,
_idle_poll_interval: Duration, // 签名保留,但内部逻辑已进化为更高效的驱动方式
stale_timeout: Duration,
should_exit: F,
) -> StreamConsumeState<T>
pub async fn next_event<F>(&mut self, stale_timeout: Duration, should_exit: F) -> StreamConsumeState<T>
where
F: Fn() -> bool,
{