Fix: display GLOBAL select

This commit is contained in:
Dreamacro 2020-06-19 21:04:06 +08:00
parent 6c04fa4cb8
commit ddc2138cb7
3 changed files with 12 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import useSWR from 'swr'
import EE from '@lib/event' import EE from '@lib/event'
import { useRound } from '@lib/hook' import { useRound } from '@lib/hook'
import { Card, Header, Icon, Checkbox } from '@components' import { Card, Header, Icon, Checkbox } from '@components'
import { useI18n, useConfig, useProxy, useProxyProviders } from '@stores' import { useI18n, useConfig, useProxy, useProxyProviders, useGeneral } from '@stores'
import * as API from '@lib/request' import * as API from '@lib/request'
import { Proxy, Group, Provider } from './components' import { Proxy, Group, Provider } from './components'
@ -28,14 +28,20 @@ export function compareDesc (a: API.Proxy, b: API.Proxy) {
} }
function ProxyGroups () { function ProxyGroups () {
const { groups } = useProxy() const { groups, global } = useProxy()
const { data: config, set: setConfig } = useConfig() const { data: config, set: setConfig } = useConfig()
const { general } = useGeneral()
const { useTranslation } = useI18n() const { useTranslation } = useI18n()
const { t } = useTranslation('Proxies') const { t } = useTranslation('Proxies')
const list = useMemo(
() => general.mode === 'global' ? [global] : groups,
[general, groups, global]
)
return <> return <>
{ {
groups.length !== 0 && list.length !== 0 &&
<div className="proxies-container"> <div className="proxies-container">
<Header title={t('groupTitle')}> <Header title={t('groupTitle')}>
<Checkbox <Checkbox
@ -48,7 +54,7 @@ function ProxyGroups () {
<Card className="proxies-group-card"> <Card className="proxies-group-card">
<ul className="proxies-group-list"> <ul className="proxies-group-list">
{ {
groups.map(p => ( list.map(p => (
<li className="proxies-group-item" key={p.name}> <li className="proxies-group-item" key={p.name}>
<Group config={p} /> <Group config={p} />
</li> </li>

View File

@ -92,7 +92,7 @@ export interface Data {
/** /**
* clash proxy mode * clash proxy mode
*/ */
mode?: string mode?: 'script' | 'rule' | 'direct' | 'global'
/** /**
* clash tty log level * clash tty log level

View File

@ -163,7 +163,7 @@ export function useGeneral () {
port: data.port, port: data.port,
socksPort: data['socks-port'], socksPort: data['socks-port'],
redirPort: data['redir-port'], redirPort: data['redir-port'],
mode: data.mode, mode: data.mode.toLowerCase() as Models.Data['general']['mode'],
logLevel: data['log-level'], logLevel: data['log-level'],
allowLan: data['allow-lan'] allowLan: data['allow-lan']
}) })