mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-14 18:35:34 +08:00
fix: init scroll from 30 && revert delay map
This commit is contained in:
parent
135111914d
commit
c260db13df
@ -3,10 +3,10 @@ import { DELAY } from '~/config/enum'
|
|||||||
import { useProxies } from '~/signals/proxies'
|
import { useProxies } from '~/signals/proxies'
|
||||||
|
|
||||||
const Delay = (props: { name?: string }) => {
|
const Delay = (props: { name?: string }) => {
|
||||||
const { proxyNodeMap } = useProxies()
|
const { delayMap } = useProxies()
|
||||||
const [textClassName, setTextClassName] = createSignal('')
|
const [textClassName, setTextClassName] = createSignal('')
|
||||||
const delay = createMemo(() => {
|
const delay = createMemo(() => {
|
||||||
return proxyNodeMap()[props.name!]?.delay!
|
return delayMap()[props.name!]
|
||||||
})
|
})
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
@ -7,7 +7,7 @@ export default (props: {
|
|||||||
now?: string
|
now?: string
|
||||||
onClick?: (name: string) => void
|
onClick?: (name: string) => void
|
||||||
}) => {
|
}) => {
|
||||||
const [maxRender, setMaxRender] = createSignal(30)
|
const [maxRender, setMaxRender] = createSignal(100)
|
||||||
const proxies = createMemo(() => props.proxies.slice(0, maxRender()))
|
const proxies = createMemo(() => props.proxies.slice(0, maxRender()))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -4,9 +4,9 @@ import { DELAY } from '~/config/enum'
|
|||||||
import { useProxies } from '~/signals/proxies'
|
import { useProxies } from '~/signals/proxies'
|
||||||
|
|
||||||
export default (props: { proxyNameList: string[]; now?: string }) => {
|
export default (props: { proxyNameList: string[]; now?: string }) => {
|
||||||
const { proxyNodeMap } = useProxies()
|
const { delayMap } = useProxies()
|
||||||
const delayList = createMemo(() =>
|
const delayList = createMemo(() =>
|
||||||
props.proxyNameList.map((i) => proxyNodeMap()[i].delay!),
|
props.proxyNameList.map((i) => delayMap()[i]),
|
||||||
)
|
)
|
||||||
const all = createMemo(() => delayList().length)
|
const all = createMemo(() => delayList().length)
|
||||||
const good = createMemo(
|
const good = createMemo(
|
||||||
|
@ -24,14 +24,18 @@ const DelayDots = (p: { delay: number | undefined; selected: boolean }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default (props: { proxyNameList: string[]; now?: string }) => {
|
export default (props: { proxyNameList: string[]; now?: string }) => {
|
||||||
const { proxyNodeMap } = useProxies()
|
const { delayMap } = useProxies()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="flex w-full flex-wrap items-center">
|
<div class="flex w-full flex-wrap items-center">
|
||||||
<For each={props.proxyNameList.map((name) => proxyNodeMap()[name]!)}>
|
<For
|
||||||
{(proxy) => {
|
each={props.proxyNameList.map((name): [string, number] => [
|
||||||
const delay = proxy?.delay
|
name,
|
||||||
const isSelected = props.now === proxy.name
|
delayMap()[name],
|
||||||
|
])}
|
||||||
|
>
|
||||||
|
{([name, delay]) => {
|
||||||
|
const isSelected = props.now === name
|
||||||
|
|
||||||
return <DelayDots delay={delay} selected={isSelected} />
|
return <DelayDots delay={delay} selected={isSelected} />
|
||||||
}}
|
}}
|
||||||
|
@ -20,7 +20,7 @@ const CHART_MAX_XAXIS = 10
|
|||||||
|
|
||||||
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
|
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
|
||||||
<div class="stat flex-1">
|
<div class="stat flex-1">
|
||||||
<div class="stat-title text-secondary-content">{props.label}</div>
|
<div class="stat-title text-primary-content">{props.label}</div>
|
||||||
<div class="stat-value text-primary-content">
|
<div class="stat-value text-primary-content">
|
||||||
{children(() => props.children)()}
|
{children(() => props.children)()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,12 +6,12 @@ type ProxyInfo = {
|
|||||||
name: string
|
name: string
|
||||||
udp: boolean
|
udp: boolean
|
||||||
type: string
|
type: string
|
||||||
delay?: number
|
|
||||||
}
|
}
|
||||||
// these signals should be global state
|
// these signals should be global state
|
||||||
const [proxies, setProxies] = createSignal<Proxy[]>([])
|
const [proxies, setProxies] = createSignal<Proxy[]>([])
|
||||||
const [proxyProviders, setProxyProviders] = createSignal<ProxyProvider[]>([])
|
const [proxyProviders, setProxyProviders] = createSignal<ProxyProvider[]>([])
|
||||||
|
|
||||||
|
const [delayMap, setDelayMap] = createSignal<Record<string, number>>({})
|
||||||
const [proxyNodeMap, setProxyNodeMap] = createSignal<Record<string, ProxyInfo>>(
|
const [proxyNodeMap, setProxyNodeMap] = createSignal<Record<string, ProxyInfo>>(
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
@ -20,15 +20,20 @@ export function useProxies() {
|
|||||||
const request = useRequest()
|
const request = useRequest()
|
||||||
const setProxyInfoByProixes = (proxies: Proxy[] | ProxyNode[]) => {
|
const setProxyInfoByProixes = (proxies: Proxy[] | ProxyNode[]) => {
|
||||||
proxies.forEach((proxy) => {
|
proxies.forEach((proxy) => {
|
||||||
|
const delay = proxy.history.at(-1)?.delay ?? 0
|
||||||
|
|
||||||
setProxyNodeMap({
|
setProxyNodeMap({
|
||||||
...proxyNodeMap(),
|
...proxyNodeMap(),
|
||||||
[proxy.name]: {
|
[proxy.name]: {
|
||||||
udp: proxy.udp,
|
udp: proxy.udp,
|
||||||
type: proxy.type,
|
type: proxy.type,
|
||||||
delay: proxy.history.at(-1)?.delay ?? 0,
|
|
||||||
name: proxy.name,
|
name: proxy.name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
setDelayMap({
|
||||||
|
...delayMap(),
|
||||||
|
[proxy.name]: delay,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const updateProxy = async () => {
|
const updateProxy = async () => {
|
||||||
@ -72,10 +77,9 @@ export function useProxies() {
|
|||||||
name: proxyName,
|
name: proxyName,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
proxyGroup.now = proxyName
|
proxyGroup.now = proxyName
|
||||||
setProxies(proxyGroupList)
|
setProxies(proxyGroupList)
|
||||||
updateProxy()
|
setTimeout(updateProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
const delayTestByProxyGroupName = async (proxyGroupName: string) => {
|
const delayTestByProxyGroupName = async (proxyGroupName: string) => {
|
||||||
@ -88,14 +92,9 @@ export function useProxies() {
|
|||||||
})
|
})
|
||||||
.json()
|
.json()
|
||||||
|
|
||||||
Object.entries(data).forEach(([name, delay]) => {
|
setDelayMap({
|
||||||
setProxyNodeMap({
|
...delayMap(),
|
||||||
...proxyNodeMap(),
|
...data,
|
||||||
[name]: {
|
|
||||||
...proxyNodeMap()[name],
|
|
||||||
delay: delay,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +114,7 @@ export function useProxies() {
|
|||||||
proxies,
|
proxies,
|
||||||
proxyProviders,
|
proxyProviders,
|
||||||
delayTestByProxyGroupName,
|
delayTestByProxyGroupName,
|
||||||
|
delayMap,
|
||||||
proxyNodeMap,
|
proxyNodeMap,
|
||||||
updateProxy,
|
updateProxy,
|
||||||
setProxyGroupByProxyName,
|
setProxyGroupByProxyName,
|
||||||
|
Loading…
Reference in New Issue
Block a user