chore: adjust type
This commit is contained in:
parent
e19fe5ce1c
commit
6eafb15cf9
@ -23,7 +23,7 @@ const Tag = styled("span")(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: ApiType.ConnectionsItem;
|
value: IConnectionsItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConnectionItem = (props: Props) => {
|
const ConnectionItem = (props: Props) => {
|
||||||
|
@ -4,7 +4,7 @@ import { DataGrid, GridColDef } from "@mui/x-data-grid";
|
|||||||
import parseTraffic from "@/utils/parse-traffic";
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
connections: ApiType.ConnectionsItem[];
|
connections: IConnectionsItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConnectionTable = (props: Props) => {
|
const ConnectionTable = (props: Props) => {
|
||||||
|
@ -45,7 +45,7 @@ const LayoutTraffic = () => {
|
|||||||
ws = new WebSocket(`ws://${server}/traffic?token=${secret}`);
|
ws = new WebSocket(`ws://${server}/traffic?token=${secret}`);
|
||||||
|
|
||||||
ws.addEventListener("message", (event) => {
|
ws.addEventListener("message", (event) => {
|
||||||
const data = JSON.parse(event.data) as ApiType.TrafficItem;
|
const data = JSON.parse(event.data) as ITrafficItem;
|
||||||
trafficRef.current?.appendData(data);
|
trafficRef.current?.appendData(data);
|
||||||
setTraffic(data);
|
setTraffic(data);
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ export default function useLogSetup() {
|
|||||||
getClashLogs().then(setLogData);
|
getClashLogs().then(setLogData);
|
||||||
|
|
||||||
const handler = (event: MessageEvent<any>) => {
|
const handler = (event: MessageEvent<any>) => {
|
||||||
const data = JSON.parse(event.data) as ApiType.LogItem;
|
const data = JSON.parse(event.data) as ILogItem;
|
||||||
const time = dayjs().format("MM-DD HH:mm:ss");
|
const time = dayjs().format("MM-DD HH:mm:ss");
|
||||||
setLogData((l) => {
|
setLogData((l) => {
|
||||||
if (l.length >= MAX_LOG_NUM) l.shift();
|
if (l.length >= MAX_LOG_NUM) l.shift();
|
||||||
|
@ -20,7 +20,7 @@ const Item = styled(Box)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: ApiType.LogItem;
|
value: ILogItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LogItem = (props: Props) => {
|
const LogItem = (props: Props) => {
|
||||||
|
@ -14,7 +14,7 @@ import ProfileMore from "./profile-more";
|
|||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
items: CmdType.ProfileItem[];
|
items: IProfileItem[];
|
||||||
chain: string[];
|
chain: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import Notice from "../base/base-notice";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
itemData: CmdType.ProfileItem;
|
itemData: IProfileItem;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ const round = keyframes`
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
itemData: CmdType.ProfileItem;
|
itemData: IProfileItem;
|
||||||
onSelect: (force: boolean) => void;
|
onSelect: (force: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ const ProfileItem = (props: Props) => {
|
|||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
setLoadingCache((cache) => ({ ...cache, [itemData.uid]: true }));
|
setLoadingCache((cache) => ({ ...cache, [itemData.uid]: true }));
|
||||||
|
|
||||||
const option: Partial<CmdType.ProfileOption> = {};
|
const option: Partial<IProfileOption> = {};
|
||||||
|
|
||||||
if (type === 0) {
|
if (type === 0) {
|
||||||
option.with_proxy = false;
|
option.with_proxy = false;
|
||||||
|
@ -21,7 +21,7 @@ import Notice from "../base/base-notice";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
itemData: CmdType.ProfileItem;
|
itemData: IProfileItem;
|
||||||
enableNum: number;
|
enableNum: number;
|
||||||
logInfo?: [string, string][];
|
logInfo?: [string, string][];
|
||||||
onEnable: () => void;
|
onEnable: () => void;
|
||||||
|
@ -13,7 +13,7 @@ import ProxyItem from "./proxy-item";
|
|||||||
interface Props {
|
interface Props {
|
||||||
groupName: string;
|
groupName: string;
|
||||||
curProxy?: string;
|
curProxy?: string;
|
||||||
proxies: ApiType.ProxyItem[];
|
proxies: IProxyItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// this component will be used for DIRECT/GLOBAL
|
// this component will be used for DIRECT/GLOBAL
|
||||||
|
@ -30,7 +30,7 @@ import ProxyHead from "./proxy-head";
|
|||||||
import ProxyItem from "./proxy-item";
|
import ProxyItem from "./proxy-item";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
group: ApiType.ProxyGroupItem;
|
group: IProxyGroupItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProxyGroup = ({ group }: Props) => {
|
const ProxyGroup = ({ group }: Props) => {
|
||||||
|
@ -17,7 +17,7 @@ import BaseLoading from "../base/base-loading";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
groupName: string;
|
groupName: string;
|
||||||
proxy: ApiType.ProxyItem;
|
proxy: IProxyItem;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
showType?: boolean;
|
showType?: boolean;
|
||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
|
@ -5,7 +5,7 @@ import delayManager from "@/services/delay";
|
|||||||
export type ProxySortType = 0 | 1 | 2;
|
export type ProxySortType = 0 | 1 | 2;
|
||||||
|
|
||||||
export default function useFilterSort(
|
export default function useFilterSort(
|
||||||
proxies: ApiType.ProxyItem[],
|
proxies: IProxyItem[],
|
||||||
groupName: string,
|
groupName: string,
|
||||||
filterText: string,
|
filterText: string,
|
||||||
sortType: ProxySortType
|
sortType: ProxySortType
|
||||||
@ -47,7 +47,7 @@ const regex2 = /type=(.*)/i;
|
|||||||
* according to the regular conditions
|
* according to the regular conditions
|
||||||
*/
|
*/
|
||||||
function filterProxies(
|
function filterProxies(
|
||||||
proxies: ApiType.ProxyItem[],
|
proxies: IProxyItem[],
|
||||||
groupName: string,
|
groupName: string,
|
||||||
filterText: string
|
filterText: string
|
||||||
) {
|
) {
|
||||||
@ -87,7 +87,7 @@ function filterProxies(
|
|||||||
* sort the proxy
|
* sort the proxy
|
||||||
*/
|
*/
|
||||||
function sortProxies(
|
function sortProxies(
|
||||||
proxies: ApiType.ProxyItem[],
|
proxies: IProxyItem[],
|
||||||
groupName: string,
|
groupName: string,
|
||||||
sortType: ProxySortType
|
sortType: ProxySortType
|
||||||
) {
|
) {
|
||||||
|
@ -19,7 +19,7 @@ const COLOR = [
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
index: number;
|
index: number;
|
||||||
value: ApiType.RuleItem;
|
value: IRuleItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseColor = (text: string) => {
|
const parseColor = (text: string) => {
|
||||||
|
@ -89,7 +89,7 @@ const SysproxyViewer = ({ handler }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const patch: Partial<CmdType.VergeConfig> = {};
|
const patch: Partial<IVergeConfig> = {};
|
||||||
|
|
||||||
if (value.guard !== enable_proxy_guard) {
|
if (value.guard !== enable_proxy_guard) {
|
||||||
patch.enable_proxy_guard = value.guard;
|
patch.enable_proxy_guard = value.guard;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button, ButtonGroup } from "@mui/material";
|
import { Button, ButtonGroup } from "@mui/material";
|
||||||
|
|
||||||
type ThemeValue = CmdType.VergeConfig["theme_mode"];
|
type ThemeValue = IVergeConfig["theme_mode"];
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value?: ThemeValue;
|
value?: ThemeValue;
|
||||||
|
@ -46,10 +46,10 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
const controllerHandler = useModalHandler();
|
const controllerHandler = useModalHandler();
|
||||||
|
|
||||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
const onChangeData = (patch: Partial<ApiType.ConfigData>) => {
|
const onChangeData = (patch: Partial<IConfigData>) => {
|
||||||
mutateClash((old) => ({ ...(old! || {}), ...patch }), false);
|
mutateClash((old) => ({ ...(old! || {}), ...patch }), false);
|
||||||
};
|
};
|
||||||
const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => {
|
const onUpdateData = async (patch: Partial<IConfigData>) => {
|
||||||
await updateConfigs(patch);
|
await updateConfigs(patch);
|
||||||
await patchClashConfig(patch);
|
await patchClashConfig(patch);
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
} = vergeConfig ?? {};
|
} = vergeConfig ?? {};
|
||||||
|
|
||||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
|
const onChangeData = (patch: Partial<IVergeConfig>) => {
|
||||||
mutateVerge({ ...vergeConfig, ...patch }, false);
|
mutateVerge({ ...vergeConfig, ...patch }, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
const [configOpen, setConfigOpen] = useState(false);
|
const [configOpen, setConfigOpen] = useState(false);
|
||||||
|
|
||||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
|
const onChangeData = (patch: Partial<IVergeConfig>) => {
|
||||||
mutateVerge({ ...vergeConfig, ...patch }, false);
|
mutateVerge({ ...vergeConfig, ...patch }, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { getVergeConfig, patchVergeConfig } from "@/services/cmds";
|
|||||||
export const useVergeConfig = () => {
|
export const useVergeConfig = () => {
|
||||||
const { data, mutate } = useSWR("getVergeConfig", getVergeConfig);
|
const { data, mutate } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
const patchVerge = async (value: Partial<CmdType.VergeConfig>) => {
|
const patchVerge = async (value: Partial<IVergeConfig>) => {
|
||||||
await patchVergeConfig(value);
|
await patchVergeConfig(value);
|
||||||
mutate();
|
mutate();
|
||||||
};
|
};
|
||||||
|
@ -22,14 +22,14 @@ import ConnectionTable from "@/components/connection/connection-table";
|
|||||||
|
|
||||||
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
||||||
|
|
||||||
type OrderFunc = (list: ApiType.ConnectionsItem[]) => ApiType.ConnectionsItem[];
|
type OrderFunc = (list: IConnectionsItem[]) => IConnectionsItem[];
|
||||||
|
|
||||||
const ConnectionsPage = () => {
|
const ConnectionsPage = () => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
const [filterText, setFilterText] = useState("");
|
const [filterText, setFilterText] = useState("");
|
||||||
const [curOrderOpt, setOrderOpt] = useState("Default");
|
const [curOrderOpt, setOrderOpt] = useState("Default");
|
||||||
const [connData, setConnData] = useState<ApiType.Connections>(initConn);
|
const [connData, setConnData] = useState<IConnections>(initConn);
|
||||||
|
|
||||||
const [setting, setSetting] = useRecoilState(atomConnectionSetting);
|
const [setting, setSetting] = useRecoilState(atomConnectionSetting);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ const ConnectionsPage = () => {
|
|||||||
ws = new WebSocket(`ws://${server}/connections?token=${secret}`);
|
ws = new WebSocket(`ws://${server}/connections?token=${secret}`);
|
||||||
|
|
||||||
ws.addEventListener("message", (event) => {
|
ws.addEventListener("message", (event) => {
|
||||||
const data = JSON.parse(event.data) as ApiType.Connections;
|
const data = JSON.parse(event.data) as IConnections;
|
||||||
|
|
||||||
// 与前一次connections的展示顺序尽量保持一致
|
// 与前一次connections的展示顺序尽量保持一致
|
||||||
setConnData((old) => {
|
setConnData((old) => {
|
||||||
|
@ -50,11 +50,11 @@ export async function getVersion() {
|
|||||||
/// Get current base configs
|
/// Get current base configs
|
||||||
export async function getClashConfig() {
|
export async function getClashConfig() {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
return instance.get("/configs") as Promise<ApiType.ConfigData>;
|
return instance.get("/configs") as Promise<IConfigData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update current configs
|
/// Update current configs
|
||||||
export async function updateConfigs(config: Partial<ApiType.ConfigData>) {
|
export async function updateConfigs(config: Partial<IConfigData>) {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
return instance.patch("/configs", config);
|
return instance.patch("/configs", config);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ export async function updateConfigs(config: Partial<ApiType.ConfigData>) {
|
|||||||
export async function getRules() {
|
export async function getRules() {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
const response = await instance.get<any, any>("/rules");
|
const response = await instance.get<any, any>("/rules");
|
||||||
return response?.rules as ApiType.RuleItem[];
|
return response?.rules as IRuleItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get Proxy delay
|
/// Get Proxy delay
|
||||||
@ -90,7 +90,7 @@ export async function updateProxy(group: string, proxy: string) {
|
|||||||
async function getProxiesInner() {
|
async function getProxiesInner() {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
const response = await instance.get<any, any>("/proxies");
|
const response = await instance.get<any, any>("/proxies");
|
||||||
return (response?.proxies || {}) as Record<string, ApiType.ProxyItem>;
|
return (response?.proxies || {}) as Record<string, IProxyItem>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the Proxy information
|
/// Get the Proxy information
|
||||||
@ -116,7 +116,7 @@ export async function getProxies() {
|
|||||||
|
|
||||||
const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord;
|
const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord;
|
||||||
|
|
||||||
let groups: ApiType.ProxyGroupItem[] = [];
|
let groups: IProxyGroupItem[] = [];
|
||||||
|
|
||||||
if (global?.all) {
|
if (global?.all) {
|
||||||
groups = global.all
|
groups = global.all
|
||||||
@ -142,7 +142,7 @@ export async function getProxies() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const _global: ApiType.ProxyGroupItem = {
|
const _global: IProxyGroupItem = {
|
||||||
...global,
|
...global,
|
||||||
all: global?.all?.map((item) => generateItem(item)) || [],
|
all: global?.all?.map((item) => generateItem(item)) || [],
|
||||||
};
|
};
|
||||||
@ -155,10 +155,7 @@ export async function getProviders() {
|
|||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
const response = await instance.get<any, any>("/providers/proxies");
|
const response = await instance.get<any, any>("/providers/proxies");
|
||||||
|
|
||||||
const providers = (response.providers || {}) as Record<
|
const providers = (response.providers || {}) as Record<string, IProviderItem>;
|
||||||
string,
|
|
||||||
ApiType.ProviderItem
|
|
||||||
>;
|
|
||||||
|
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
Object.entries(providers).filter(([key, item]) => {
|
Object.entries(providers).filter(([key, item]) => {
|
||||||
@ -179,7 +176,7 @@ export async function providerHealthCheck(name: string) {
|
|||||||
export async function getConnections() {
|
export async function getConnections() {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
const result = await instance.get("/connections");
|
const result = await instance.get("/connections");
|
||||||
return result as any as ApiType.Connections;
|
return result as any as IConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close specific connection
|
// Close specific connection
|
||||||
|
@ -21,23 +21,23 @@ export async function getClashLogs() {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.filter(Boolean) as ApiType.LogItem[];
|
.filter(Boolean) as ILogItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProfiles() {
|
export async function getProfiles() {
|
||||||
return invoke<CmdType.ProfilesConfig>("get_profiles");
|
return invoke<IProfilesConfig>("get_profiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function enhanceProfiles() {
|
export async function enhanceProfiles() {
|
||||||
return invoke<void>("enhance_profiles");
|
return invoke<void>("enhance_profiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function patchProfilesConfig(profiles: CmdType.ProfilesConfig) {
|
export async function patchProfilesConfig(profiles: IProfilesConfig) {
|
||||||
return invoke<void>("patch_profiles_config", { profiles });
|
return invoke<void>("patch_profiles_config", { profiles });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createProfile(
|
export async function createProfile(
|
||||||
item: Partial<CmdType.ProfileItem>,
|
item: Partial<IProfileItem>,
|
||||||
fileData?: string | null
|
fileData?: string | null
|
||||||
) {
|
) {
|
||||||
return invoke<void>("create_profile", { item, fileData });
|
return invoke<void>("create_profile", { item, fileData });
|
||||||
@ -62,10 +62,7 @@ export async function importProfile(url: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateProfile(
|
export async function updateProfile(index: string, option?: IProfileOption) {
|
||||||
index: string,
|
|
||||||
option?: CmdType.ProfileOption
|
|
||||||
) {
|
|
||||||
return invoke<void>("update_profile", { index, option });
|
return invoke<void>("update_profile", { index, option });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,13 +72,13 @@ export async function deleteProfile(index: string) {
|
|||||||
|
|
||||||
export async function patchProfile(
|
export async function patchProfile(
|
||||||
index: string,
|
index: string,
|
||||||
profile: Partial<CmdType.ProfileItem>
|
profile: Partial<IProfileItem>
|
||||||
) {
|
) {
|
||||||
return invoke<void>("patch_profile", { index, profile });
|
return invoke<void>("patch_profile", { index, profile });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getClashInfo() {
|
export async function getClashInfo() {
|
||||||
return invoke<CmdType.ClashInfo | null>("get_clash_info");
|
return invoke<IClashInfo | null>("get_clash_info");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRuntimeConfig() {
|
export async function getRuntimeConfig() {
|
||||||
@ -100,15 +97,15 @@ export async function getRuntimeLogs() {
|
|||||||
return invoke<Record<string, [string, string][]>>("get_runtime_logs");
|
return invoke<Record<string, [string, string][]>>("get_runtime_logs");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function patchClashConfig(payload: Partial<ApiType.ConfigData>) {
|
export async function patchClashConfig(payload: Partial<IConfigData>) {
|
||||||
return invoke<void>("patch_clash_config", { payload });
|
return invoke<void>("patch_clash_config", { payload });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVergeConfig() {
|
export async function getVergeConfig() {
|
||||||
return invoke<CmdType.VergeConfig>("get_verge_config");
|
return invoke<IVergeConfig>("get_verge_config");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function patchVergeConfig(payload: CmdType.VergeConfig) {
|
export async function patchVergeConfig(payload: IVergeConfig) {
|
||||||
return invoke<void>("patch_verge_config", { payload });
|
return invoke<void>("patch_verge_config", { payload });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class DelayManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 暂时修复provider的节点延迟排序的问题
|
/// 暂时修复provider的节点延迟排序的问题
|
||||||
getDelayFix(proxy: ApiType.ProxyItem, group: string) {
|
getDelayFix(proxy: IProxyItem, group: string) {
|
||||||
if (!proxy.provider) return this.getDelay(proxy.name, group);
|
if (!proxy.provider) return this.getDelay(proxy.name, group);
|
||||||
|
|
||||||
if (proxy.history.length > 0) {
|
if (proxy.history.length > 0) {
|
||||||
|
@ -10,7 +10,7 @@ export const atomClashPort = atom<number>({
|
|||||||
default: 0,
|
default: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const atomLogData = atom<ApiType.LogItem[]>({
|
export const atomLogData = atom<ILogItem[]>({
|
||||||
key: "atomLogData",
|
key: "atomLogData",
|
||||||
default: [],
|
default: [],
|
||||||
});
|
});
|
||||||
@ -50,10 +50,10 @@ export const atomConnectionSetting = atom<IConnectionSetting>({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const value = localStorage.getItem(key);
|
const value = localStorage.getItem(key);
|
||||||
const data = value == null ? { layout: "list" } : JSON.parse(value);
|
const data = value == null ? { layout: "table" } : JSON.parse(value);
|
||||||
setSelf(data);
|
setSelf(data);
|
||||||
} catch {
|
} catch {
|
||||||
setSelf({ layout: "list" });
|
setSelf({ layout: "table" });
|
||||||
}
|
}
|
||||||
|
|
||||||
onSet((newValue) => {
|
onSet((newValue) => {
|
||||||
|
453
src/services/types.d.ts
vendored
453
src/services/types.d.ts
vendored
@ -1,243 +1,240 @@
|
|||||||
/**
|
/**
|
||||||
* Some interface for clash api
|
* Some interface for clash api
|
||||||
*/
|
*/
|
||||||
declare namespace ApiType {
|
interface IConfigData {
|
||||||
interface ConfigData {
|
port: number;
|
||||||
port: number;
|
mode: string;
|
||||||
mode: string;
|
ipv6: boolean;
|
||||||
ipv6: boolean;
|
"socket-port": number;
|
||||||
"socket-port": number;
|
"allow-lan": boolean;
|
||||||
"allow-lan": boolean;
|
"log-level": string;
|
||||||
"log-level": string;
|
"mixed-port": number;
|
||||||
"mixed-port": number;
|
"redir-port": number;
|
||||||
"redir-port": number;
|
"socks-port": number;
|
||||||
"socks-port": number;
|
"tproxy-port": number;
|
||||||
"tproxy-port": number;
|
"external-controller": string;
|
||||||
"external-controller": string;
|
secret: string;
|
||||||
secret: string;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
interface RuleItem {
|
interface IRuleItem {
|
||||||
|
type: string;
|
||||||
|
payload: string;
|
||||||
|
proxy: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IProxyItem {
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
udp: boolean;
|
||||||
|
history: {
|
||||||
|
time: string;
|
||||||
|
delay: number;
|
||||||
|
}[];
|
||||||
|
all?: string[];
|
||||||
|
now?: string;
|
||||||
|
provider?: string; // 记录是否来自provider
|
||||||
|
}
|
||||||
|
|
||||||
|
type IProxyGroupItem = Omit<IProxyItem, "all"> & {
|
||||||
|
all: IProxyItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IProviderItem {
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
proxies: IProxyItem[];
|
||||||
|
updatedAt: string;
|
||||||
|
vehicleType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ITrafficItem {
|
||||||
|
up: number;
|
||||||
|
down: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ILogItem {
|
||||||
|
type: string;
|
||||||
|
time?: string;
|
||||||
|
payload: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IConnectionsItem {
|
||||||
|
id: string;
|
||||||
|
metadata: {
|
||||||
|
network: string;
|
||||||
type: string;
|
type: string;
|
||||||
payload: string;
|
host: string;
|
||||||
proxy: string;
|
sourceIP: string;
|
||||||
}
|
sourcePort: string;
|
||||||
|
destinationPort: string;
|
||||||
interface ProxyItem {
|
destinationIP?: string;
|
||||||
name: string;
|
process?: string;
|
||||||
type: string;
|
processPath?: string;
|
||||||
udp: boolean;
|
|
||||||
history: {
|
|
||||||
time: string;
|
|
||||||
delay: number;
|
|
||||||
}[];
|
|
||||||
all?: string[];
|
|
||||||
now?: string;
|
|
||||||
provider?: string; // 记录是否来自provider
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProxyGroupItem = Omit<ProxyItem, "all"> & {
|
|
||||||
all: ProxyItem[];
|
|
||||||
};
|
};
|
||||||
|
upload: number;
|
||||||
|
download: number;
|
||||||
|
start: string;
|
||||||
|
chains: string[];
|
||||||
|
rule: string;
|
||||||
|
rulePayload: string;
|
||||||
|
curUpload?: number; // upload speed, calculate at runtime
|
||||||
|
curDownload?: number; // download speed, calculate at runtime
|
||||||
|
}
|
||||||
|
|
||||||
interface ProviderItem {
|
interface IConnections {
|
||||||
name: string;
|
downloadTotal: number;
|
||||||
type: string;
|
uploadTotal: number;
|
||||||
proxies: ProxyItem[];
|
connections: IConnectionsItem[];
|
||||||
updatedAt: string;
|
|
||||||
vehicleType: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TrafficItem {
|
|
||||||
up: number;
|
|
||||||
down: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LogItem {
|
|
||||||
type: string;
|
|
||||||
time?: string;
|
|
||||||
payload: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ConnectionsItem {
|
|
||||||
id: string;
|
|
||||||
metadata: {
|
|
||||||
network: string;
|
|
||||||
type: string;
|
|
||||||
host: string;
|
|
||||||
sourceIP: string;
|
|
||||||
sourcePort: string;
|
|
||||||
destinationPort: string;
|
|
||||||
destinationIP?: string;
|
|
||||||
process?: string;
|
|
||||||
processPath?: string;
|
|
||||||
};
|
|
||||||
upload: number;
|
|
||||||
download: number;
|
|
||||||
start: string;
|
|
||||||
chains: string[];
|
|
||||||
rule: string;
|
|
||||||
rulePayload: string;
|
|
||||||
curUpload?: number; // upload speed, calculate at runtime
|
|
||||||
curDownload?: number; // download speed, calculate at runtime
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Connections {
|
|
||||||
downloadTotal: number;
|
|
||||||
uploadTotal: number;
|
|
||||||
connections: ConnectionsItem[];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some interface for command
|
* Some interface for command
|
||||||
*/
|
*/
|
||||||
declare namespace CmdType {
|
|
||||||
type ProfileType = "local" | "remote" | "merge" | "script";
|
|
||||||
|
|
||||||
interface ClashInfo {
|
type IProfileType = "local" | "remote" | "merge" | "script";
|
||||||
status: string;
|
|
||||||
port?: string; // clash mixed port
|
|
||||||
server?: string; // external-controller
|
|
||||||
secret?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProfileItem {
|
interface IClashInfo {
|
||||||
uid: string;
|
status: string;
|
||||||
type?: ProfileType | string;
|
port?: string; // clash mixed port
|
||||||
name?: string;
|
server?: string; // external-controller
|
||||||
desc?: string;
|
secret?: string;
|
||||||
file?: string;
|
}
|
||||||
url?: string;
|
|
||||||
updated?: number;
|
interface IProfileItem {
|
||||||
selected?: {
|
uid: string;
|
||||||
name?: string;
|
type?: IProfileType | string;
|
||||||
now?: string;
|
name?: string;
|
||||||
}[];
|
desc?: string;
|
||||||
extra?: {
|
file?: string;
|
||||||
upload: number;
|
url?: string;
|
||||||
download: number;
|
updated?: number;
|
||||||
total: number;
|
selected?: {
|
||||||
expire: number;
|
name?: string;
|
||||||
};
|
now?: string;
|
||||||
option?: ProfileOption;
|
}[];
|
||||||
}
|
extra?: {
|
||||||
|
upload: number;
|
||||||
interface ProfileOption {
|
download: number;
|
||||||
user_agent?: string;
|
total: number;
|
||||||
with_proxy?: boolean;
|
expire: number;
|
||||||
self_proxy?: boolean;
|
};
|
||||||
update_interval?: number;
|
option?: IProfileOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProfilesConfig {
|
interface IProfileOption {
|
||||||
current?: string;
|
user_agent?: string;
|
||||||
chain?: string[];
|
with_proxy?: boolean;
|
||||||
valid?: string[];
|
self_proxy?: boolean;
|
||||||
items?: ProfileItem[];
|
update_interval?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VergeConfig {
|
interface IProfilesConfig {
|
||||||
language?: string;
|
current?: string;
|
||||||
clash_core?: string;
|
chain?: string[];
|
||||||
theme_mode?: "light" | "dark" | "system";
|
valid?: string[];
|
||||||
theme_blur?: boolean;
|
items?: IProfileItem[];
|
||||||
traffic_graph?: boolean;
|
}
|
||||||
enable_tun_mode?: boolean;
|
|
||||||
enable_auto_launch?: boolean;
|
interface IVergeConfig {
|
||||||
enable_service_mode?: boolean;
|
language?: string;
|
||||||
enable_silent_start?: boolean;
|
clash_core?: string;
|
||||||
enable_system_proxy?: boolean;
|
theme_mode?: "light" | "dark" | "system";
|
||||||
enable_proxy_guard?: boolean;
|
theme_blur?: boolean;
|
||||||
proxy_guard_duration?: number;
|
traffic_graph?: boolean;
|
||||||
system_proxy_bypass?: string;
|
enable_tun_mode?: boolean;
|
||||||
web_ui_list?: string[];
|
enable_auto_launch?: boolean;
|
||||||
hotkeys?: string[];
|
enable_service_mode?: boolean;
|
||||||
theme_setting?: {
|
enable_silent_start?: boolean;
|
||||||
primary_color?: string;
|
enable_system_proxy?: boolean;
|
||||||
secondary_color?: string;
|
enable_proxy_guard?: boolean;
|
||||||
primary_text?: string;
|
proxy_guard_duration?: number;
|
||||||
secondary_text?: string;
|
system_proxy_bypass?: string;
|
||||||
info_color?: string;
|
web_ui_list?: string[];
|
||||||
error_color?: string;
|
hotkeys?: string[];
|
||||||
warning_color?: string;
|
theme_setting?: {
|
||||||
success_color?: string;
|
primary_color?: string;
|
||||||
font_family?: string;
|
secondary_color?: string;
|
||||||
css_injection?: string;
|
primary_text?: string;
|
||||||
};
|
secondary_text?: string;
|
||||||
auto_close_connection?: boolean;
|
info_color?: string;
|
||||||
default_latency_test?: string;
|
error_color?: string;
|
||||||
}
|
warning_color?: string;
|
||||||
|
success_color?: string;
|
||||||
type ClashConfigValue = any;
|
font_family?: string;
|
||||||
|
css_injection?: string;
|
||||||
interface ProfileMerge {
|
};
|
||||||
// clash config fields (default supports)
|
auto_close_connection?: boolean;
|
||||||
rules?: ClashConfigValue;
|
default_latency_test?: string;
|
||||||
proxies?: ClashConfigValue;
|
}
|
||||||
"proxy-groups"?: ClashConfigValue;
|
|
||||||
"proxy-providers"?: ClashConfigValue;
|
type IClashConfigValue = any;
|
||||||
"rule-providers"?: ClashConfigValue;
|
|
||||||
// clash config fields (use flag)
|
interface IProfileMerge {
|
||||||
tun?: ClashConfigValue;
|
// clash config fields (default supports)
|
||||||
dns?: ClashConfigValue;
|
rules?: IClashConfigValue;
|
||||||
hosts?: ClashConfigValue;
|
proxies?: IClashConfigValue;
|
||||||
script?: ClashConfigValue;
|
"proxy-groups"?: IClashConfigValue;
|
||||||
profile?: ClashConfigValue;
|
"proxy-providers"?: IClashConfigValue;
|
||||||
payload?: ClashConfigValue;
|
"rule-providers"?: IClashConfigValue;
|
||||||
"interface-name"?: ClashConfigValue;
|
// clash config fields (use flag)
|
||||||
"routing-mark"?: ClashConfigValue;
|
tun?: IClashConfigValue;
|
||||||
// functional fields
|
dns?: IClashConfigValue;
|
||||||
use?: string[];
|
hosts?: IClashConfigValue;
|
||||||
"prepend-rules"?: any[];
|
script?: IClashConfigValue;
|
||||||
"append-rules"?: any[];
|
profile?: IClashConfigValue;
|
||||||
"prepend-proxies"?: any[];
|
payload?: IClashConfigValue;
|
||||||
"append-proxies"?: any[];
|
"interface-name"?: IClashConfigValue;
|
||||||
"prepend-proxy-groups"?: any[];
|
"routing-mark"?: IClashConfigValue;
|
||||||
"append-proxy-groups"?: any[];
|
// functional fields
|
||||||
// fix
|
use?: string[];
|
||||||
ebpf?: any;
|
"prepend-rules"?: any[];
|
||||||
experimental?: any;
|
"append-rules"?: any[];
|
||||||
iptables?: any;
|
"prepend-proxies"?: any[];
|
||||||
sniffer?: any;
|
"append-proxies"?: any[];
|
||||||
authentication?: any;
|
"prepend-proxy-groups"?: any[];
|
||||||
"bind-address"?: any;
|
"append-proxy-groups"?: any[];
|
||||||
"external-ui"?: any;
|
// fix
|
||||||
"auto-redir"?: any;
|
ebpf?: any;
|
||||||
"socks-port"?: any;
|
experimental?: any;
|
||||||
"redir-port"?: any;
|
iptables?: any;
|
||||||
"tproxy-port"?: any;
|
sniffer?: any;
|
||||||
"geodata-mode"?: any;
|
authentication?: any;
|
||||||
"tcp-concurrent"?: any;
|
"bind-address"?: any;
|
||||||
}
|
"external-ui"?: any;
|
||||||
|
"auto-redir"?: any;
|
||||||
// partial of the clash config
|
"socks-port"?: any;
|
||||||
type ProfileData = Partial<{
|
"redir-port"?: any;
|
||||||
rules: any[];
|
"tproxy-port"?: any;
|
||||||
proxies: any[];
|
"geodata-mode"?: any;
|
||||||
"proxy-groups": any[];
|
"tcp-concurrent"?: any;
|
||||||
"proxy-providers": any[];
|
}
|
||||||
"rule-providers": any[];
|
|
||||||
|
// partial of the clash config
|
||||||
[k: string]: any;
|
type IProfileData = Partial<{
|
||||||
}>;
|
rules: any[];
|
||||||
|
proxies: any[];
|
||||||
interface ChainItem {
|
"proxy-groups": any[];
|
||||||
item: ProfileItem;
|
"proxy-providers": any[];
|
||||||
merge?: ProfileMerge;
|
"rule-providers": any[];
|
||||||
script?: string;
|
|
||||||
}
|
[k: string]: any;
|
||||||
|
}>;
|
||||||
interface EnhancedPayload {
|
|
||||||
chain: ChainItem[];
|
interface IChainItem {
|
||||||
valid: string[];
|
item: IProfileItem;
|
||||||
current: ProfileData;
|
merge?: IProfileMerge;
|
||||||
callback: string;
|
script?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EnhancedResult {
|
interface IEnhancedPayload {
|
||||||
data: ProfileData;
|
chain: IChainItem[];
|
||||||
status: string;
|
valid: string[];
|
||||||
error?: string;
|
current: IProfileData;
|
||||||
}
|
callback: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IEnhancedResult {
|
||||||
|
data: IProfileData;
|
||||||
|
status: string;
|
||||||
|
error?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user