chore: todo

This commit is contained in:
oomeow
2025-10-01 10:17:08 +08:00
Unverified
parent 223747e932
commit ae9e4faa7b
11 changed files with 27 additions and 11 deletions

View File

@@ -106,7 +106,7 @@ pub async fn restart_core() -> CmdResult {
result
}
/// 获取代理延迟
// 获取代理延迟
// #[tauri::command]
// pub async fn clash_api_get_proxy_delay(
// name: String,

View File

@@ -31,7 +31,7 @@ use crate::{
// Ok((*value).clone())
// }
/// 强制刷新代理缓存用于profile切换
// 强制刷新代理缓存用于profile切换
// #[tauri::command]
// pub async fn force_refresh_proxies() -> CmdResult<serde_json::Value> {
// let cache = CacheProxy::global();

View File

@@ -25,6 +25,10 @@ use std::{
};
use tauri_plugin_shell::{ShellExt, process::CommandChild};
// TODO:
// - 重构,提升模式切换速度
// - 内核启动添加启动 IPC 启动参数, `-ext-ctl-unix` / `-ext-ctl-pipe`, 运行时配置需要删除相关配置项
#[derive(Debug)]
pub struct CoreManager {
running: Arc<Mutex<RunningMode>>,

View File

@@ -284,6 +284,7 @@ impl Handle {
}
/// 获取 AppHandle
#[allow(clippy::expect_used)]
pub fn app_handle() -> &'static AppHandle {
APP_HANDLE.get().expect("failed to get global app handle")
}

View File

@@ -31,6 +31,11 @@ use tauri::{
tray::{MouseButton, MouseButtonState, TrayIconEvent},
};
// TODO:
// - 定时更新代理菜单(5s)
// - 前端选择节点/代理组测速后,发送 event 事件Tray 监听此事件
// - 是否需要将可变菜单抽离存储起来,后续直接更新对应菜单实例,无需重新创建菜单(待考虑)
#[derive(Clone)]
struct TrayState {}
@@ -187,7 +192,7 @@ singleton_lazy!(Tray, TRAY, Tray::default);
impl Tray {
pub async fn init(&self) -> Result<()> {
let app_handle = handle::Handle::app_handle();
self.create_tray_from_handle(&app_handle).await?;
self.create_tray_from_handle(app_handle).await?;
Ok(())
}
@@ -238,7 +243,7 @@ impl Tray {
// 设置更新状态
self.menu_updating.store(true, Ordering::Release);
let result = self.update_menu_internal(&app_handle).await;
let result = self.update_menu_internal(app_handle).await;
{
let mut last_update = self.last_menu_update.lock();
@@ -658,7 +663,7 @@ async fn create_tray_menu(
_ => {
current_profile_selected
.iter()
.any(|s| s.name.as_deref() == Some(&group_name))
.any(|s| s.name.as_deref() == Some(group_name))
&& !now_proxy.is_empty()
}
};

View File

@@ -314,6 +314,7 @@ pub fn run() {
.setup(|app| {
logging!(info, Type::Setup, true, "开始应用初始化...");
#[allow(clippy::expect_used)]
APP_HANDLE
.set(app.app_handle().clone())
.expect("failed to set global app handle");

View File

@@ -1,4 +1,5 @@
/// Format bytes into human readable string (B, KB, MB, GB)
#[allow(unused)]
pub fn fmt_bytes(bytes: u64) -> String {
const UNITS: &[&str] = &["B", "KB", "MB", "GB"];
let (mut val, mut unit) = (bytes as f64, 0);

View File

@@ -28,7 +28,7 @@ pub enum Type {
Lightweight,
Network,
ProxyMode,
Ipc,
// Ipc,
// Cache,
ClashVergeRev,
}
@@ -51,7 +51,7 @@ impl fmt::Display for Type {
Type::Lightweight => write!(f, "[Lightweight]"),
Type::Network => write!(f, "[Network]"),
Type::ProxyMode => write!(f, "[ProxMode]"),
Type::Ipc => write!(f, "[IPC]"),
// Type::Ipc => write!(f, "[IPC]"),
// Type::Cache => write!(f, "[Cache]"),
Type::ClashVergeRev => write!(f, "[ClashVergeRev]"),
}