Skip to content

Commit 4784540

Browse files
committed
feat: hide Global group for singbox
1 parent f3d772c commit 4784540

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/store/proxies.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ClashAPIConfig } from 'src/types';
1616

1717
import * as connAPI from '../api/connections';
1818
import * as proxiesAPI from '../api/proxies';
19+
import { fetchVersion } from 'src/api/version'; // 导入 fetchVersion
1920
import { getAutoCloseOldConns, getLatencyTestUrl } from './app';
2021

2122
export const initialState: StateProxies = {
@@ -67,6 +68,8 @@ function mapLatency(names: string[], getProxy: (name: string) => { history: Late
6768

6869
export function fetchProxies(apiConfig: ClashAPIConfig) {
6970
return async (dispatch: any, getState: any) => {
71+
const { meta, premium } = await fetchVersion('/version', apiConfig);
72+
7073
const [proxiesData, providersData] = await Promise.all([
7174
proxiesAPI.fetchProxies(apiConfig),
7275
proxiesAPI.fetchProviderProxies(apiConfig),
@@ -75,7 +78,7 @@ export function fetchProxies(apiConfig: ClashAPIConfig) {
7578
const { proxyProviders, providerProxyRecord } = formatProxyProviders(providersData.providers);
7679

7780
const proxies = { ...providerProxyRecord, ...proxiesData.proxies };
78-
const [groupNames, proxyNames] = retrieveGroupNamesFrom(proxies);
81+
const [groupNames, proxyNames] = retrieveGroupNamesFrom(proxies, { meta, premium });
7982

8083
const delayNext = {
8184
...getDelay(getState()),
@@ -357,13 +360,19 @@ export function requestDelayAll(apiConfig: ClashAPIConfig) {
357360
};
358361
}
359362

360-
function retrieveGroupNamesFrom(proxies: Record<string, ProxyItem>) {
363+
function retrieveGroupNamesFrom(
364+
proxies: Record<string, ProxyItem>,
365+
version: { meta: boolean; premium: boolean }
366+
) {
361367
let groupNames = [];
362368
let globalAll: string[];
363369
const proxyNames = [];
364370
for (const prop in proxies) {
365371
const p = proxies[prop];
366372
if (p.all && Array.isArray(p.all)) {
373+
if (prop === 'GLOBAL' && version.meta && version.premium) {
374+
continue;
375+
}
367376
groupNames.push(prop);
368377
if (prop === 'GLOBAL') {
369378
globalAll = Array.from(p.all);

0 commit comments

Comments
 (0)