fix: card click

This commit is contained in:
Zephyruso 2023-09-01 18:37:19 +08:00
parent 275238f9b8
commit 25cbdad8bc
2 changed files with 19 additions and 3 deletions

View File

@ -2,7 +2,11 @@ import InfiniteScroll from 'solid-infinite-scroll'
import { createMemo, createSignal } from 'solid-js'
import ProxyNodeCard from './ProxyNodeCard'
export default (props: { proxies: string[]; now?: string }) => {
export default (props: {
proxies: string[]
now?: string
onClick?: (name: string) => void
}) => {
const [maxRender, setMaxRender] = createSignal(30)
const proxies = createMemo(() => props.proxies.slice(0, maxRender()))
@ -13,7 +17,13 @@ export default (props: { proxies: string[]; now?: string }) => {
next={() => setMaxRender(maxRender() + 30)}
>
{(proxy) => (
<ProxyNodeCard proxyName={proxy} isSelected={props.now === proxy} />
<ProxyNodeCard
proxyName={proxy}
isSelected={props.now === proxy}
onClick={() => {
props.onClick?.(proxy!)
}}
/>
)}
</InfiniteScroll>
)

View File

@ -90,7 +90,13 @@ export default () => {
)
const content = (
<ProxyCardGroups proxies={proxy.all!} now={proxy.now} />
<ProxyCardGroups
proxies={proxy.all!}
now={proxy.now}
onClick={(name) => {
setProxyGroupByProxyName(proxy, name)
}}
/>
)
return (