chore: todo
This commit is contained in:
@@ -106,7 +106,7 @@ pub async fn restart_core() -> CmdResult {
|
||||
result
|
||||
}
|
||||
|
||||
/// 获取代理延迟
|
||||
// 获取代理延迟
|
||||
// #[tauri::command]
|
||||
// pub async fn clash_api_get_proxy_delay(
|
||||
// name: String,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>>,
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]"),
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ import { Virtuoso, type VirtuosoHandle } from "react-virtuoso";
|
||||
import { useProxySelection } from "@/hooks/use-proxy-selection";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import { useAppData } from "@/providers/app-data-provider";
|
||||
import { updateProxyChainConfigInRuntime } from "@/services/cmds";
|
||||
import {
|
||||
getRuntimeConfig,
|
||||
updateProxyChainConfigInRuntime,
|
||||
} from "@/services/cmds";
|
||||
import delayManager from "@/services/delay";
|
||||
|
||||
import { BaseEmpty } from "../base";
|
||||
@@ -28,6 +31,8 @@ import { ProxyRender } from "./proxy-render";
|
||||
import { ProxyGroupNavigator } from "./proxy-group-navigator";
|
||||
import { useRenderList } from "./use-render-list";
|
||||
import { delayGroup, healthcheckProxyProvider } from "tauri-plugin-mihomo-api";
|
||||
import useSWR from "swr";
|
||||
import { useMemo } from "react";
|
||||
|
||||
interface Props {
|
||||
mode: string;
|
||||
@@ -209,6 +214,7 @@ export const ProxyGroups = (props: Props) => {
|
||||
const currentGroup = getCurrentGroup();
|
||||
const availableGroups = getAvailableGroups();
|
||||
|
||||
// TODO: 频繁点击切换代理节点,导致应用卡死
|
||||
const handleChangeProxy = useCallback(
|
||||
(group: IProxyGroupItem, proxy: IProxyItem) => {
|
||||
if (isChainMode) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { List, Paper, ThemeProvider, SvgIcon } from "@mui/material";
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import { useLocalStorage } from "foxact/use-local-storage";
|
||||
import { useEffect, useCallback, useState, useRef } from "react";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -37,7 +36,6 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
import { showNotice } from "@/services/noticeService";
|
||||
import { NoticeManager } from "@/components/base/NoticeManager";
|
||||
import { LogLevel } from "@/hooks/use-log-data";
|
||||
import { useMemoryData } from "@/hooks/use-memory-data";
|
||||
import { useTrafficData } from "@/hooks/use-traffic-data";
|
||||
import { useConnectionData } from "@/hooks/use-connection-data";
|
||||
|
||||
@@ -334,7 +334,7 @@ export const AppDataProvider = ({
|
||||
// 高频率更新数据 (2秒)
|
||||
const { data: uptimeData } = useSWR("appUptime", getAppUptime, {
|
||||
// TODO: 运行时间
|
||||
refreshInterval: 20000,
|
||||
refreshInterval: 2000,
|
||||
revalidateOnFocus: false,
|
||||
suspense: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user