chore: update
This commit is contained in:
@@ -31,10 +31,7 @@ use tauri::{
|
|||||||
tray::{MouseButton, MouseButtonState, TrayIconEvent},
|
tray::{MouseButton, MouseButtonState, TrayIconEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO:
|
// TODO: 是否需要将可变菜单抽离存储起来,后续直接更新对应菜单实例,无需重新创建菜单(待考虑)
|
||||||
// - 定时更新代理菜单(5s)
|
|
||||||
// - 前端选择节点/代理组测速后,发送 event 事件,Tray 监听此事件
|
|
||||||
// - 是否需要将可变菜单抽离存储起来,后续直接更新对应菜单实例,无需重新创建菜单(待考虑)
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct TrayState {}
|
struct TrayState {}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const ClashInfoCard = () => {
|
|||||||
{t("Mixed Port")}
|
{t("Mixed Port")}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" fontWeight="medium">
|
<Typography variant="body2" fontWeight="medium">
|
||||||
{clashConfig["mixed-port"] || "-"}
|
{clashConfig.mixedPort || "-"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import useSWR, { mutate } from "swr";
|
import useSWR, { mutate } from "swr";
|
||||||
|
import { getVersion } from "tauri-plugin-mihomo-api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getClashInfo,
|
getClashInfo,
|
||||||
patchClashConfig,
|
patchClashConfig,
|
||||||
getRuntimeConfig,
|
getRuntimeConfig,
|
||||||
} from "@/services/cmds";
|
} from "@/services/cmds";
|
||||||
import { getVersion } from "tauri-plugin-mihomo-api";
|
|
||||||
|
|
||||||
export const useClash = () => {
|
export const useClash = () => {
|
||||||
const { data: clash, mutate: mutateClash } = useSWR(
|
const { data: clash, mutate: mutateClash } = useSWR(
|
||||||
|
|||||||
@@ -2,14 +2,18 @@ import { listen } from "@tauri-apps/api/event";
|
|||||||
import React, { createContext, use, useEffect, useMemo, useRef } from "react";
|
import React, { createContext, use, useEffect, useMemo, useRef } from "react";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import {
|
import {
|
||||||
|
BaseConfig,
|
||||||
getBaseConfig,
|
getBaseConfig,
|
||||||
getRuleProviders,
|
getRuleProviders,
|
||||||
getRules,
|
getRules,
|
||||||
|
ProxyProvider,
|
||||||
|
Rule,
|
||||||
|
RuleProvider,
|
||||||
} from "tauri-plugin-mihomo-api";
|
} from "tauri-plugin-mihomo-api";
|
||||||
|
|
||||||
import { useClashInfo } from "@/hooks/use-clash";
|
// import { useClashInfo } from "@/hooks/use-clash";
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
import { useVisibility } from "@/hooks/use-visibility";
|
// import { useVisibility } from "@/hooks/use-visibility";
|
||||||
import {
|
import {
|
||||||
calcuProxies,
|
calcuProxies,
|
||||||
calcuProxyProviders,
|
calcuProxyProviders,
|
||||||
@@ -31,16 +35,16 @@ interface ConnectionWithSpeed extends IConnectionsItem {
|
|||||||
curDownload: number;
|
curDownload: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义AppDataContext类型 - 使用宽松类型
|
// 定义AppDataContext类型
|
||||||
interface AppDataContextType {
|
interface AppDataContextType {
|
||||||
proxies: any;
|
proxies: any;
|
||||||
clashConfig: any;
|
clashConfig: BaseConfig;
|
||||||
rules: any[];
|
rules: Rule[];
|
||||||
sysproxy: any;
|
sysproxy: any;
|
||||||
runningMode?: string;
|
runningMode?: string;
|
||||||
uptime: number;
|
uptime: number;
|
||||||
proxyProviders: any;
|
proxyProviders: Record<string, ProxyProvider>;
|
||||||
ruleProviders: any;
|
ruleProviders: Record<string, RuleProvider>;
|
||||||
// connections: {
|
// connections: {
|
||||||
// data: ConnectionWithSpeed[];
|
// data: ConnectionWithSpeed[];
|
||||||
// count: number;
|
// count: number;
|
||||||
@@ -69,8 +73,8 @@ export const AppDataProvider = ({
|
|||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) => {
|
}) => {
|
||||||
const pageVisible = useVisibility();
|
// const pageVisible = useVisibility();
|
||||||
const { clashInfo } = useClashInfo();
|
// const { clashInfo } = useClashInfo();
|
||||||
const { verge } = useVerge();
|
const { verge } = useVerge();
|
||||||
|
|
||||||
// 存储上一次连接数据用于速度计算
|
// 存储上一次连接数据用于速度计算
|
||||||
@@ -157,6 +161,8 @@ export const AppDataProvider = ({
|
|||||||
|
|
||||||
lastProfileId = newProfileId;
|
lastProfileId = newProfileId;
|
||||||
lastUpdateTime = now;
|
lastUpdateTime = now;
|
||||||
|
refreshRules();
|
||||||
|
refreshRuleProviders();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听Clash配置刷新事件(enhance操作等)
|
// 监听Clash配置刷新事件(enhance操作等)
|
||||||
@@ -502,7 +508,7 @@ export const AppDataProvider = ({
|
|||||||
refreshProxyProviders,
|
refreshProxyProviders,
|
||||||
refreshRuleProviders,
|
refreshRuleProviders,
|
||||||
refreshAll,
|
refreshAll,
|
||||||
};
|
} as AppDataContextType;
|
||||||
}, [
|
}, [
|
||||||
proxiesData,
|
proxiesData,
|
||||||
clashConfig,
|
clashConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user