diff --git a/src/components/Delay.tsx b/src/components/Delay.tsx
index 999d8ce..408ea7e 100644
--- a/src/components/Delay.tsx
+++ b/src/components/Delay.tsx
@@ -3,10 +3,10 @@ import { DELAY } from '~/config/enum'
import { useProxies } from '~/signals/proxies'
const Delay = (props: { name?: string }) => {
- const { proxyNodeMap } = useProxies()
+ const { delayMap } = useProxies()
const [textClassName, setTextClassName] = createSignal('')
const delay = createMemo(() => {
- return proxyNodeMap()[props.name!]?.delay!
+ return delayMap()[props.name!]
})
createEffect(() => {
diff --git a/src/components/ProxyCardGroups.tsx b/src/components/ProxyCardGroups.tsx
index 3113fa0..89af17e 100644
--- a/src/components/ProxyCardGroups.tsx
+++ b/src/components/ProxyCardGroups.tsx
@@ -7,7 +7,7 @@ export default (props: {
now?: string
onClick?: (name: string) => void
}) => {
- const [maxRender, setMaxRender] = createSignal(30)
+ const [maxRender, setMaxRender] = createSignal(100)
const proxies = createMemo(() => props.proxies.slice(0, maxRender()))
return (
diff --git a/src/components/ProxyPreviewBar.tsx b/src/components/ProxyPreviewBar.tsx
index 0bcfdb4..f766ab9 100644
--- a/src/components/ProxyPreviewBar.tsx
+++ b/src/components/ProxyPreviewBar.tsx
@@ -4,9 +4,9 @@ import { DELAY } from '~/config/enum'
import { useProxies } from '~/signals/proxies'
export default (props: { proxyNameList: string[]; now?: string }) => {
- const { proxyNodeMap } = useProxies()
+ const { delayMap } = useProxies()
const delayList = createMemo(() =>
- props.proxyNameList.map((i) => proxyNodeMap()[i].delay!),
+ props.proxyNameList.map((i) => delayMap()[i]),
)
const all = createMemo(() => delayList().length)
const good = createMemo(
diff --git a/src/components/ProxyPreviewDots.tsx b/src/components/ProxyPreviewDots.tsx
index 9361be1..6af14c3 100644
--- a/src/components/ProxyPreviewDots.tsx
+++ b/src/components/ProxyPreviewDots.tsx
@@ -24,14 +24,18 @@ const DelayDots = (p: { delay: number | undefined; selected: boolean }) => {
}
export default (props: { proxyNameList: string[]; now?: string }) => {
- const { proxyNodeMap } = useProxies()
+ const { delayMap } = useProxies()
return (
-
proxyNodeMap()[name]!)}>
- {(proxy) => {
- const delay = proxy?.delay
- const isSelected = props.now === proxy.name
+ [
+ name,
+ delayMap()[name],
+ ])}
+ >
+ {([name, delay]) => {
+ const isSelected = props.now === name
return
}}
diff --git a/src/pages/Overview.tsx b/src/pages/Overview.tsx
index b04968b..678c44c 100644
--- a/src/pages/Overview.tsx
+++ b/src/pages/Overview.tsx
@@ -20,7 +20,7 @@ const CHART_MAX_XAXIS = 10
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
-
{props.label}
+
{props.label}
{children(() => props.children)()}
diff --git a/src/signals/proxies.ts b/src/signals/proxies.ts
index 75b8e31..f491ef4 100644
--- a/src/signals/proxies.ts
+++ b/src/signals/proxies.ts
@@ -6,12 +6,12 @@ type ProxyInfo = {
name: string
udp: boolean
type: string
- delay?: number
}
// these signals should be global state
const [proxies, setProxies] = createSignal
([])
const [proxyProviders, setProxyProviders] = createSignal([])
+const [delayMap, setDelayMap] = createSignal>({})
const [proxyNodeMap, setProxyNodeMap] = createSignal>(
{},
)
@@ -20,15 +20,20 @@ export function useProxies() {
const request = useRequest()
const setProxyInfoByProixes = (proxies: Proxy[] | ProxyNode[]) => {
proxies.forEach((proxy) => {
+ const delay = proxy.history.at(-1)?.delay ?? 0
+
setProxyNodeMap({
...proxyNodeMap(),
[proxy.name]: {
udp: proxy.udp,
type: proxy.type,
- delay: proxy.history.at(-1)?.delay ?? 0,
name: proxy.name,
},
})
+ setDelayMap({
+ ...delayMap(),
+ [proxy.name]: delay,
+ })
})
}
const updateProxy = async () => {
@@ -72,10 +77,9 @@ export function useProxies() {
name: proxyName,
}),
})
-
proxyGroup.now = proxyName
setProxies(proxyGroupList)
- updateProxy()
+ setTimeout(updateProxy)
}
const delayTestByProxyGroupName = async (proxyGroupName: string) => {
@@ -88,14 +92,9 @@ export function useProxies() {
})
.json()
- Object.entries(data).forEach(([name, delay]) => {
- setProxyNodeMap({
- ...proxyNodeMap(),
- [name]: {
- ...proxyNodeMap()[name],
- delay: delay,
- },
- })
+ setDelayMap({
+ ...delayMap(),
+ ...data,
})
}
@@ -115,6 +114,7 @@ export function useProxies() {
proxies,
proxyProviders,
delayTestByProxyGroupName,
+ delayMap,
proxyNodeMap,
updateProxy,
setProxyGroupByProxyName,