diff --git a/src/main/core/mihomoApi.ts b/src/main/core/mihomoApi.ts index 7a7ca2d8..89d309da 100644 --- a/src/main/core/mihomoApi.ts +++ b/src/main/core/mihomoApi.ts @@ -114,11 +114,6 @@ export const mihomoUpdateProxyProviders = async (name: string): Promise => return await instance.put(`/providers/proxies/${encodeURIComponent(name)}`) } -export const mihomoRunProxyProviders = async (): Promise => { - const runtime = await getRuntimeConfig() - return runtime?.['proxy-providers'] -} - export const mihomoRuleProviders = async (): Promise => { const instance = await getAxios() return await instance.get('/providers/rules') @@ -129,11 +124,6 @@ export const mihomoUpdateRuleProviders = async (name: string): Promise => return await instance.put(`/providers/rules/${encodeURIComponent(name)}`) } -export const mihomoRunRuleProviders = async (): Promise => { - const runtime = await getRuntimeConfig() - return runtime?.['rule-providers'] -} - export const mihomoChangeProxy = async (group: string, proxy: string): Promise => { const instance = await getAxios() return await instance.put(`/proxies/${encodeURIComponent(group)}`, { name: proxy }) @@ -204,9 +194,9 @@ const mihomoTraffic = async (): Promise => { if (process.platform !== 'linux') { tray?.setToolTip( '↑' + - `${calcTraffic(json.up)}/s`.padStart(9) + - '\n↓' + - `${calcTraffic(json.down)}/s`.padStart(9) + `${calcTraffic(json.up)}/s`.padStart(9) + + '\n↓' + + `${calcTraffic(json.down)}/s`.padStart(9) ) } floatingWindow?.webContents.send('mihomoTraffic', json) diff --git a/src/main/utils/ipc.ts b/src/main/utils/ipc.ts index 48ab902c..c8021628 100644 --- a/src/main/utils/ipc.ts +++ b/src/main/utils/ipc.ts @@ -8,9 +8,7 @@ import { mihomoProxies, mihomoProxyDelay, mihomoProxyProviders, - mihomoRunProxyProviders, mihomoRuleProviders, - mihomoRunRuleProviders, mihomoRules, mihomoUnfixedProxy, mihomoUpdateProxyProviders, @@ -119,12 +117,10 @@ export function registerIpcMainHandlers(): void { ipcMain.handle('mihomoProxies', ipcErrorWrapper(mihomoProxies)) ipcMain.handle('mihomoGroups', ipcErrorWrapper(mihomoGroups)) ipcMain.handle('mihomoProxyProviders', ipcErrorWrapper(mihomoProxyProviders)) - ipcMain.handle('mihomoRunProxyProviders', ipcErrorWrapper(mihomoRunProxyProviders)) ipcMain.handle('mihomoUpdateProxyProviders', (_e, name) => ipcErrorWrapper(mihomoUpdateProxyProviders)(name) ) ipcMain.handle('mihomoRuleProviders', ipcErrorWrapper(mihomoRuleProviders)) - ipcMain.handle('mihomoRunRuleProviders', ipcErrorWrapper(mihomoRunRuleProviders)) ipcMain.handle('mihomoUpdateRuleProviders', (_e, name) => ipcErrorWrapper(mihomoUpdateRuleProviders)(name) ) diff --git a/src/renderer/src/components/connections/connection-detail-modal.tsx b/src/renderer/src/components/connections/connection-detail-modal.tsx index a5674960..40e7ad28 100644 --- a/src/renderer/src/components/connections/connection-detail-modal.tsx +++ b/src/renderer/src/components/connections/connection-detail-modal.tsx @@ -32,7 +32,7 @@ const CopyableSettingItem: React.FC<{ : prefix.flatMap(p => (p === 'DOMAIN-SUFFIX' ? getSubDomains(Array.isArray(value) ? value[0] : value) - : p === 'IP-ASN' + : p === 'IP-ASN' || p === 'SRC-IP-ASN' ? [(Array.isArray(value) ? value[0] : value).split(' ')[0]] : [Array.isArray(value) ? value[0] : value] ).map(v => ({ diff --git a/src/renderer/src/components/resources/proxy-provider.tsx b/src/renderer/src/components/resources/proxy-provider.tsx index da1d0a32..f58d4f2c 100644 --- a/src/renderer/src/components/resources/proxy-provider.tsx +++ b/src/renderer/src/components/resources/proxy-provider.tsx @@ -1,4 +1,8 @@ -import { mihomoProxyProviders, mihomoUpdateProxyProviders, mihomoRunProxyProviders } from '@renderer/utils/ipc' +import { + mihomoProxyProviders, + mihomoUpdateProxyProviders, + getRuntimeConfigStr +} from '@renderer/utils/ipc' import { Fragment, useEffect, useMemo, useState } from 'react' import Viewer from './viewer' import useSWR from 'swr' @@ -7,6 +11,7 @@ import SettingItem from '../base/base-setting-item' import { Button, Chip } from '@nextui-org/react' import { IoMdRefresh, IoMdEye } from 'react-icons/io' import { CgLoadbarDoc } from 'react-icons/cg' +import { MdEditDocument } from 'react-icons/md' import dayjs from 'dayjs' import { calcTraffic } from '@renderer/utils/calc' import { getHash } from '@renderer/utils/hash' @@ -19,7 +24,7 @@ const ProxyProvider: React.FC = () => { useEffect(() => { const fetchProviderPath = async (name: string) => { try { - const providers = await mihomoRunProxyProviders() + const providers = await getRuntimeConfigStr()?.['rule-providers'] const provider = providers[name] if (provider?.path) { setShowPath(provider.path) @@ -73,7 +78,17 @@ const ProxyProvider: React.FC = () => { return ( - {ShowProvider && { setShowProvider(false); setShowPath(''); setShowType('')}} path={ShowPath} type={ShowType} />} + {ShowProvider && ( + { + setShowProvider(false) + setShowPath('') + setShowType('') + }} + path={ShowPath} + type={ShowType} + /> + )} - diff --git a/src/renderer/src/components/resources/rule-provider.tsx b/src/renderer/src/components/resources/rule-provider.tsx index 05d5e326..dc158279 100644 --- a/src/renderer/src/components/resources/rule-provider.tsx +++ b/src/renderer/src/components/resources/rule-provider.tsx @@ -1,4 +1,8 @@ -import { mihomoRuleProviders, mihomoUpdateRuleProviders, mihomoRunRuleProviders } from '@renderer/utils/ipc' +import { + mihomoRuleProviders, + mihomoUpdateRuleProviders, + getRuntimeConfigStr +} from '@renderer/utils/ipc' import { getHash } from '@renderer/utils/hash' import Viewer from './viewer' import { Fragment, useEffect, useMemo, useState } from 'react' @@ -8,6 +12,7 @@ import SettingItem from '../base/base-setting-item' import { Button, Chip } from '@nextui-org/react' import { IoMdRefresh } from 'react-icons/io' import { CgLoadbarDoc } from 'react-icons/cg' +import { MdEditDocument } from 'react-icons/md' import dayjs from 'dayjs' const RuleProvider: React.FC = () => { @@ -27,7 +32,7 @@ const RuleProvider: React.FC = () => { useEffect(() => { const fetchProviderPath = async (name: string) => { try { - const providers = await mihomoRunRuleProviders() + const providers = await getRuntimeConfigStr()?.['rule-providers'] const provider = providers[name] if (provider?.path) { setShowPath(provider.path) @@ -68,12 +73,18 @@ const RuleProvider: React.FC = () => { return ( - {ShowProvider && { setShowProvider(false); setShowPath(''); setShowType('') }} - />} + {ShowProvider && ( + { + setShowProvider(false) + setShowPath('') + setShowType('') + }} + /> + )} - {provider.format !== "MrsRule" && ( + {provider.format !== 'MrsRule' && ( )} + { ) } -export async function mihomoRunProxyProviders(): Promise { - return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRunProxyProviders')) -} - export async function mihomoRuleProviders(): Promise { return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRuleProviders')) } @@ -57,10 +53,6 @@ export async function mihomoUpdateRuleProviders(name: string): Promise { ) } -export async function mihomoRunRuleProviders(): Promise { - return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRunRuleProviders')) -} - export async function mihomoChangeProxy(group: string, proxy: string): Promise { return ipcErrorWrapper( await window.electron.ipcRenderer.invoke('mihomoChangeProxy', group, proxy) diff --git a/src/shared/types.d.ts b/src/shared/types.d.ts index d7665139..fc474ca7 100644 --- a/src/shared/types.d.ts +++ b/src/shared/types.d.ts @@ -181,8 +181,6 @@ interface IMihomoRuleProvider { type: string updatedAt: string vehicleType: string - url: string - path: string } interface IMihomoProxyProviders { @@ -205,8 +203,6 @@ interface IMihomoProxyProvider { testUrl?: string updatedAt?: string vehicleType: string - url: string - path: string } interface ISysProxyConfig {