mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Feature: Group can display unhealth node
This commit is contained in:
parent
48668b9312
commit
8f41bb5da1
@ -8,13 +8,14 @@ import './style.scss'
|
|||||||
interface TagsProps extends BaseComponentProps {
|
interface TagsProps extends BaseComponentProps {
|
||||||
data: string[]
|
data: string[]
|
||||||
onClick: (name: string) => void
|
onClick: (name: string) => void
|
||||||
|
shouldError?: (name: string) => boolean
|
||||||
select: string
|
select: string
|
||||||
rowHeight: number
|
rowHeight: number
|
||||||
canClick: boolean
|
canClick: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Tags (props: TagsProps) {
|
export function Tags (props: TagsProps) {
|
||||||
const { className, data, onClick, select, canClick, rowHeight: rawHeight } = props
|
const { className, data, onClick, select, canClick, shouldError, rowHeight: rawHeight } = props
|
||||||
|
|
||||||
const { useTranslation } = containers.useI18n()
|
const { useTranslation } = containers.useI18n()
|
||||||
const { t } = useTranslation('Proxies')
|
const { t } = useTranslation('Proxies')
|
||||||
@ -35,7 +36,7 @@ export function Tags (props: TagsProps) {
|
|||||||
|
|
||||||
const tags = data
|
const tags = data
|
||||||
.map(t => {
|
.map(t => {
|
||||||
const tagClass = classnames({ 'tags-selected': select === t, 'can-click': canClick })
|
const tagClass = classnames({ 'tags-selected': select === t, 'can-click': canClick, error: shouldError && shouldError(t) })
|
||||||
return (
|
return (
|
||||||
<li className={tagClass} key={t} onClick={() => handleClick(t)}>
|
<li className={tagClass} key={t} onClick={() => handleClick(t)}>
|
||||||
{ t }
|
{ t }
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
@import '~@styles/variables';
|
@import '~@styles/variables';
|
||||||
|
|
||||||
$height: 22px;
|
$height: 22px;
|
||||||
$add-height: 25px;
|
|
||||||
$delete-height: 22px;
|
|
||||||
|
|
||||||
.tags-container {
|
.tags-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -37,6 +35,19 @@ $delete-height: 22px;
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.error {
|
||||||
|
color: #fff;
|
||||||
|
background-color: $color-red;
|
||||||
|
border-color: $color-red;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.tags-selected.error {
|
||||||
|
background: linear-gradient(135deg, $color-primary-dark, $color-red);
|
||||||
|
border: none;
|
||||||
|
height: $height + 2px;
|
||||||
|
padding: 0 7px;
|
||||||
|
}
|
||||||
|
|
||||||
.tags-selected {
|
.tags-selected {
|
||||||
background-color: $color-primary-dark;
|
background-color: $color-primary-dark;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
@ -9,7 +9,7 @@ interface GroupProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Group (props: GroupProps) {
|
export function Group (props: GroupProps) {
|
||||||
const { fetch } = containers.useData()
|
const { fetch, data: Data } = containers.useData()
|
||||||
const { data: Config } = containers.useConfig()
|
const { data: Config } = containers.useConfig()
|
||||||
const { config } = props
|
const { config } = props
|
||||||
|
|
||||||
@ -31,6 +31,15 @@ export function Group (props: GroupProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldError (name: string) {
|
||||||
|
const history = Data.proxyMap.get(name)?.history
|
||||||
|
if (history?.length) {
|
||||||
|
return !history.slice(-1)[0].delay
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const canClick = config.type === 'Selector'
|
const canClick = config.type === 'Selector'
|
||||||
return (
|
return (
|
||||||
<div className="proxy-group">
|
<div className="proxy-group">
|
||||||
@ -43,6 +52,7 @@ export function Group (props: GroupProps) {
|
|||||||
className="proxy-group-tags"
|
className="proxy-group-tags"
|
||||||
data={config.all}
|
data={config.all}
|
||||||
onClick={handleChangeProxySelected}
|
onClick={handleChangeProxySelected}
|
||||||
|
shouldError={shouldError}
|
||||||
select={config.now}
|
select={config.now}
|
||||||
canClick={canClick}
|
canClick={canClick}
|
||||||
rowHeight={30} />
|
rowHeight={30} />
|
||||||
|
@ -51,7 +51,7 @@ interface History {
|
|||||||
|
|
||||||
export interface Proxy {
|
export interface Proxy {
|
||||||
name: string
|
name: string
|
||||||
type: 'Direct' | 'Reject' | 'Shadowsocks' | 'Vmess' | 'Socks' | 'Http'
|
type: 'Direct' | 'Reject' | 'Shadowsocks' | 'Vmess' | 'Socks' | 'Http' | 'Snell'
|
||||||
history: History[]
|
history: History[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,4 +118,6 @@ export interface Data {
|
|||||||
proxyProviders?: API.Provider[]
|
proxyProviders?: API.Provider[]
|
||||||
|
|
||||||
rules?: API.Rule[]
|
rules?: API.Rule[]
|
||||||
|
|
||||||
|
proxyMap?: Map<string, API.Proxy>
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ function useData () {
|
|||||||
proxy: [],
|
proxy: [],
|
||||||
proxyGroup: [],
|
proxyGroup: [],
|
||||||
proxyProviders: [],
|
proxyProviders: [],
|
||||||
rules: []
|
rules: [],
|
||||||
|
proxyMap: new Map<string, API.Proxy>()
|
||||||
})
|
})
|
||||||
|
|
||||||
const { visible, show, hide } = useVisible()
|
const { visible, show, hide } = useVisible()
|
||||||
@ -51,11 +52,23 @@ function useData () {
|
|||||||
.filter(pd => pd.name !== 'default')
|
.filter(pd => pd.name !== 'default')
|
||||||
.filter(pd => pd.vehicleType !== 'Compatible')
|
.filter(pd => pd.vehicleType !== 'Compatible')
|
||||||
|
|
||||||
|
const proxyMap = new Map<string, API.Proxy>()
|
||||||
|
for (const p of proxy) {
|
||||||
|
proxyMap.set(p.name, p as API.Proxy)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const provider of providers) {
|
||||||
|
for (const p of provider.proxies) {
|
||||||
|
proxyMap.set(p.name, p as API.Proxy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set({
|
set({
|
||||||
proxy: proxy as API.Proxy[],
|
proxy: proxy as API.Proxy[],
|
||||||
proxyGroup: general.mode === 'Global' ? [proxyList] : groups as API.Group[],
|
proxyGroup: general.mode === 'Global' ? [proxyList] : groups as API.Group[],
|
||||||
proxyProviders: providers,
|
proxyProviders: providers,
|
||||||
rules: rules.data.rules
|
rules: rules.data.rules,
|
||||||
|
proxyMap
|
||||||
})
|
})
|
||||||
|
|
||||||
const [version, vErr] = await to(API.getVersion())
|
const [version, vErr] = await to(API.getVersion())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user