diff --git a/src/renderer/src/components/rules/rule-item.tsx b/src/renderer/src/components/rules/rule-item.tsx index 1d7a5c1..b2fba09 100644 --- a/src/renderer/src/components/rules/rule-item.tsx +++ b/src/renderer/src/components/rules/rule-item.tsx @@ -12,13 +12,11 @@ const RuleItem: React.FC = (props) => { const { type, payload, proxy, index: listIndex, extra } = props const ruleIndex = props.index ?? listIndex - const { disabled, hitCount, hitAt, missCount, missAt } = extra - - const [isEnabled, setIsEnabled] = useState(!disabled) + const [isEnabled, setIsEnabled] = useState(!extra?.disabled) useEffect(() => { - setIsEnabled(!disabled) - }, [disabled]) + setIsEnabled(!extra?.disabled) + }, [extra?.disabled]) const handleToggle = async (v: boolean): Promise => { setIsEnabled(v) @@ -30,9 +28,6 @@ const RuleItem: React.FC = (props) => { } } - const totalCount = hitCount + missCount - const hitRate = totalCount > 0 ? (hitCount / totalCount) * 100 : 0 - const formatRelativeTime = (timestamp: string): string => { const now = Date.now() const time = new Date(timestamp).getTime() @@ -43,8 +38,6 @@ const RuleItem: React.FC = (props) => { return t('rules.hitAt.days', { count: Math.floor(diff / 86400) }) } - const hasStats = totalCount > 0 - return (
@@ -67,29 +60,33 @@ const RuleItem: React.FC = (props) => {
- {/* 统计信息 */} - {hasStats && ( -
- - {formatRelativeTime(hitAt || missAt)} - - - {hitCount}/{totalCount} - - - {hitRate.toFixed(1)}% - -
- )} - {/* 右侧开关 */} - + {extra && (() => { + const total = extra.hitCount + extra.missCount + const rate = total > 0 ? (extra.hitCount / total) * 100 : 0 + return ( + <> +
+ + {formatRelativeTime(extra.hitAt || extra.missAt)} + + + {extra.hitCount}/{total} + + + {rate.toFixed(1)}% + +
+ + + ) + })()} diff --git a/src/shared/types.d.ts b/src/shared/types.d.ts index 62edb93..70733a6 100644 --- a/src/shared/types.d.ts +++ b/src/shared/types.d.ts @@ -3,7 +3,7 @@ type LogLevel = 'info' | 'debug' | 'warning' | 'error' | 'silent' type SysProxyMode = 'auto' | 'manual' type CardStatus = 'col-span-2' | 'col-span-1' | 'hidden' type AppTheme = 'system' | 'light' | 'dark' -type MihomoGroupType = 'Selector' | 'URLTest' | 'LoadBalance' | 'Relay' +type MihomoGroupType = 'Selector' | 'URLTest' | 'Fallback' | 'LoadBalance' | 'Relay' type Priority = | 'PRIORITY_LOW' | 'PRIORITY_BELOW_NORMAL' @@ -31,10 +31,15 @@ type MihomoProxyType = | 'Hysteria2' | 'Tuic' | 'WireGuard' + | 'Mieru' + | 'AnyTLS' + | 'Sudoku' + | 'Masque' + | 'TrustTunnel' type TunStack = 'gvisor' | 'mixed' | 'system' type FindProcessMode = 'off' | 'strict' | 'always' -type DnsMode = 'normal' | 'fake-ip' | 'redir-host' -type FilterMode = 'blacklist' | 'whitelist' +type DnsMode = 'normal' | 'fake-ip' | 'redir-host' | 'hosts' +type FilterMode = 'blacklist' | 'whitelist' | 'rule' type NetworkInterfaceInfo = os.NetworkInterfaceInfo interface IAppVersion { @@ -73,7 +78,7 @@ interface IMihomoRulesDetail { proxy: string size: number index: number - extra: { + extra?: { disabled: boolean hitCount: number hitAt: string @@ -124,6 +129,7 @@ interface IMihomoConnectionDetail { download: number start: string chains: string[] + providerChains: string[] rule: string rulePayload: string } @@ -149,9 +155,14 @@ interface IMihomoProxy { tfo: boolean type: MihomoProxyType udp: boolean + uot: boolean xudp: boolean mptcp: boolean smux: boolean + interface?: string + 'routing-mark'?: number + 'provider-name'?: string + 'dialer-proxy'?: string } interface IMihomoGroup { @@ -159,6 +170,7 @@ interface IMihomoGroup { all: string[] extra: Record testUrl?: string + expectedStatus?: string fixed?: string hidden: boolean history: IMihomoHistory[] @@ -191,6 +203,7 @@ interface IMihomoRuleProvider { type: string updatedAt: string vehicleType: string + payload?: string[] } interface IMihomoProxyProviders {