auto pin global group
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / artifact (push) Blocked by required conditions
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions

This commit is contained in:
pompurin404 2024-10-14 23:49:59 +08:00
parent b4a9da92f6
commit dcb59e767c
No known key found for this signature in database
15 changed files with 213 additions and 188 deletions

View File

@ -147,7 +147,8 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
child.stdout?.on('data', async (data) => {
if (data.toString().includes('Start initial Compatible provider default')) {
try {
mainWindow?.webContents.send('coreRestart')
mainWindow?.webContents.send('groupsUpdated')
mainWindow?.webContents.send('rulesUpdated')
await uploadRuntimeConfig()
} catch {
// ignore

View File

@ -76,6 +76,8 @@ export const mihomoProxies = async (): Promise<IMihomoProxies> => {
}
export const mihomoGroups = async (): Promise<IMihomoMixedGroup[]> => {
const { mode = 'rule' } = await getControledMihomoConfig()
if (mode === 'direct') return []
const proxies = await mihomoProxies()
const runtime = await getRuntimeConfig()
const groups: IMihomoMixedGroup[] = []
@ -95,6 +97,10 @@ export const mihomoGroups = async (): Promise<IMihomoMixedGroup[]> => {
groups.push({ ...newGlobal, all: newAll })
}
}
if (mode === 'global') {
const global = groups.findIndex((group) => group.name === 'GLOBAL')
groups.unshift(groups.splice(global, 1)[0])
}
return groups
}

View File

@ -111,6 +111,7 @@ export const buildContextMenu = async (): Promise<Menu> => {
await patchControledMihomoConfig({ mode: 'rule' })
await patchMihomoConfig({ mode: 'rule' })
mainWindow?.webContents.send('controledMihomoConfigUpdated')
mainWindow?.webContents.send('groupsUpdated')
ipcMain.emit('updateTrayMenu')
}
},
@ -124,6 +125,7 @@ export const buildContextMenu = async (): Promise<Menu> => {
await patchControledMihomoConfig({ mode: 'global' })
await patchMihomoConfig({ mode: 'global' })
mainWindow?.webContents.send('controledMihomoConfigUpdated')
mainWindow?.webContents.send('groupsUpdated')
ipcMain.emit('updateTrayMenu')
}
},
@ -137,6 +139,7 @@ export const buildContextMenu = async (): Promise<Menu> => {
await patchControledMihomoConfig({ mode: 'direct' })
await patchMihomoConfig({ mode: 'direct' })
mainWindow?.webContents.send('controledMihomoConfigUpdated')
mainWindow?.webContents.send('groupsUpdated')
ipcMain.emit('updateTrayMenu')
}
},

View File

@ -22,7 +22,7 @@ const CollapseInput: React.FC<CollapseInputProps> = (props) => {
}}
endContent={
<div
className="cursor-pointer p-2 text-lg text-default-500"
className="cursor-pointer p-2 text-lg text-foreground-500"
onClick={(e) => {
e.stopPropagation()
inputRef.current?.focus()

View File

@ -51,7 +51,7 @@ const ConnectionItem: React.FC<Props> = (props) => {
info.metadata.destinationIP ||
info.metadata.remoteDestination}
</div>
<small className="whitespace-nowrap text-default-500">
<small className="whitespace-nowrap text-foreground-500">
{dayjs(info.start).fromNow()}
</small>
</CardHeader>

View File

@ -16,7 +16,7 @@ const LogItem: React.FC<IMihomoLogInfo & { index: number }> = (props) => {
<div className={`mr-2 text-lg font-bold text-${colorMap[type]}`}>
{props.type.toUpperCase()}
</div>
<small className="text-default-500">{time}</small>
<small className="text-foreground-500">{time}</small>
</CardHeader>
<CardBody className="pt-0 text-sm">{payload}</CardBody>
</Card>

View File

@ -34,7 +34,7 @@ const EditFileModal: React.FC<Props> = (props) => {
<ModalHeader className="flex pb-0 app-drag">
<div className="flex justify-start">
<div className="flex items-center"></div>
<small className="ml-2 text-default-500">
<small className="ml-2 text-foreground-500">
使
<Button
size="sm"

View File

@ -63,7 +63,7 @@ const ProxyItem: React.FC<Props> = (props) => {
{proxy.name}
</div>
{proxyDisplayMode === 'full' && (
<div className="inline ml-2 text-default-500" title={proxy.type}>
<div className="inline ml-2 text-foreground-500" title={proxy.type}>
{proxy.type}
</div>
)}

View File

@ -71,7 +71,7 @@ const ProxyProvider: React.FC = () => {
divider={!provider.subscriptionInfo && index !== providers.length - 1}
>
{
<div className="flex h-[32px] leading-[32px] text-default-500">
<div className="flex h-[32px] leading-[32px] text-foreground-500">
<div>{dayjs(provider.updatedAt).fromNow()}</div>
<Button
isIconOnly
@ -90,14 +90,14 @@ const ProxyProvider: React.FC = () => {
<SettingItem
divider={index !== providers.length - 1}
title={
<div className="text-default-500">{`${calcTraffic(
<div className="text-foreground-500">{`${calcTraffic(
provider.subscriptionInfo.Upload + provider.subscriptionInfo.Download
)}
/${calcTraffic(provider.subscriptionInfo.Total)}`}</div>
}
>
{provider.subscriptionInfo && (
<div className="h-[32px] leading-[32px] text-default-500">
<div className="h-[32px] leading-[32px] text-foreground-500">
{provider.subscriptionInfo.Expire
? dayjs.unix(provider.subscriptionInfo.Expire).format('YYYY-MM-DD')
: '长期有效'}

View File

@ -65,7 +65,7 @@ const RuleProvider: React.FC = () => {
}
>
{
<div className="flex h-[32px] leading-[32px] text-default-500">
<div className="flex h-[32px] leading-[32px] text-foreground-500">
<div>{dayjs(provider.updatedAt).fromNow()}</div>
<Button
isIconOnly
@ -81,10 +81,10 @@ const RuleProvider: React.FC = () => {
}
</SettingItem>
<SettingItem
title={<div className="text-default-500">{provider.format}</div>}
title={<div className="text-foreground-500">{provider.format}</div>}
divider={index !== providers.length - 1}
>
<div className="h-[32px] leading-[32px] text-default-500">
<div className="h-[32px] leading-[32px] text-foreground-500">
{provider.vehicleType}::{provider.behavior}
</div>
</SettingItem>

View File

@ -10,7 +10,7 @@ const RuleItem: React.FC<IMihomoRulesDetail & { index: number }> = (props) => {
<div title={payload} className="text-ellipsis whitespace-nowrap overflow-hidden">
{payload}
</div>
<div className="flex justify-start text-default-500">
<div className="flex justify-start text-foreground-500">
<div>{type}</div>
<div className="ml-2">{proxy}</div>
</div>

View File

@ -1,11 +1,13 @@
import { Tabs, Tab } from '@nextui-org/react'
import { useAppConfig } from '@renderer/hooks/use-app-config'
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
import { useGroups } from '@renderer/hooks/use-groups'
import { mihomoCloseAllConnections, patchMihomoConfig } from '@renderer/utils/ipc'
import { Key } from 'react'
const OutboundModeSwitcher: React.FC = () => {
const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig()
const { mutate: mutateGroups } = useGroups()
const { appConfig } = useAppConfig()
const { autoCloseConnection = true } = appConfig || {}
const { mode } = controledMihomoConfig || {}
@ -16,6 +18,7 @@ const OutboundModeSwitcher: React.FC = () => {
if (autoCloseConnection) {
await mihomoCloseAllConnections()
}
mutateGroups()
window.electron.ipcRenderer.send('updateTrayMenu')
}
if (!mode) return null

View File

@ -16,11 +16,11 @@ export const GroupsProvider: React.FC<{ children: ReactNode }> = ({ children })
})
React.useEffect(() => {
window.electron.ipcRenderer.on('coreRestart', () => {
window.electron.ipcRenderer.on('groupsUpdated', () => {
mutate()
})
return (): void => {
window.electron.ipcRenderer.removeAllListeners('coreRestart')
window.electron.ipcRenderer.removeAllListeners('groupsUpdated')
}
}, [])

View File

@ -16,11 +16,11 @@ export const RulesProvider: React.FC<{ children: ReactNode }> = ({ children }) =
})
React.useEffect(() => {
window.electron.ipcRenderer.on('coreRestart', () => {
window.electron.ipcRenderer.on('rulesUpdated', () => {
mutate()
})
return (): void => {
window.electron.ipcRenderer.removeAllListeners('coreRestart')
window.electron.ipcRenderer.removeAllListeners('rulesUpdated')
}
}, [])

View File

@ -15,12 +15,15 @@ import { useEffect, useMemo, useRef, useState } from 'react'
import { GroupedVirtuoso, GroupedVirtuosoHandle } from 'react-virtuoso'
import ProxyItem from '@renderer/components/proxies/proxy-item'
import { IoIosArrowBack } from 'react-icons/io'
import { MdOutlineSpeed } from 'react-icons/md'
import { MdDoubleArrow, MdOutlineSpeed } from 'react-icons/md'
import { useGroups } from '@renderer/hooks/use-groups'
import CollapseInput from '@renderer/components/base/collapse-input'
import { includesIgnoreCase } from '@renderer/utils/includes'
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
const Proxies: React.FC = () => {
const { controledMihomoConfig } = useControledMihomoConfig()
const { mode = 'rule' } = controledMihomoConfig || {}
const { groups = [], mutate } = useGroups()
const { appConfig, patchAppConfig } = useAppConfig()
const {
@ -197,6 +200,14 @@ const Proxies: React.FC = () => {
</>
}
>
{mode === 'direct' ? (
<div className="h-full w-full flex justify-center items-center">
<div className="flex flex-col items-center">
<MdDoubleArrow className="text-foreground-500 text-[100px]" />
<h2 className="text-foreground-500 text-[20px]"></h2>
</div>
</div>
) : (
<div className="h-[calc(100vh-50px)]">
<GroupedVirtuoso
ref={virtuosoRef}
@ -253,13 +264,13 @@ const Proxies: React.FC = () => {
{proxyDisplayMode === 'full' && (
<div
title={groups[index].type}
className="inline ml-2 text-sm text-default-500"
className="inline ml-2 text-sm text-foreground-500"
>
{groups[index].type}
</div>
)}
{proxyDisplayMode === 'full' && (
<div className="inline flag-emoji ml-2 text-sm text-default-500">
<div className="inline flag-emoji ml-2 text-sm text-foreground-500">
{groups[index].now}
</div>
)}
@ -310,7 +321,7 @@ const Proxies: React.FC = () => {
})
}}
>
<FaLocationCrosshairs className="text-lg text-default-500" />
<FaLocationCrosshairs className="text-lg text-foreground-500" />
</Button>
<Button
title="延迟测试"
@ -322,10 +333,10 @@ const Proxies: React.FC = () => {
onGroupDelay(index)
}}
>
<MdOutlineSpeed className="text-lg text-default-500" />
<MdOutlineSpeed className="text-lg text-foreground-500" />
</Button>
<IoIosArrowBack
className={`transition duration-200 ml-2 h-[32px] text-lg text-default-500 ${isOpen[index] ? '-rotate-90' : ''}`}
className={`transition duration-200 ml-2 h-[32px] text-lg text-foreground-500 ${isOpen[index] ? '-rotate-90' : ''}`}
/>
</div>
</div>
@ -375,6 +386,7 @@ const Proxies: React.FC = () => {
}}
/>
</div>
)}
</BasePage>
)
}