mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +08:00
chore: rename func and fix params type
This commit is contained in:
parent
1729329c58
commit
16cb0debb9
0
src/components/IconButton.tsx
Normal file
0
src/components/IconButton.tsx
Normal file
@ -5,9 +5,9 @@ export const formatTimeFromNow = (time: number | string) => {
|
|||||||
return dayjs(time).fromNow()
|
return dayjs(time).fromNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handlerBtnClickWithAnimate = async (
|
export const handleAnimatedBtnClickWithCallback = async (
|
||||||
event: MouseEvent,
|
event: MouseEvent,
|
||||||
cb: () => void,
|
callback: () => Promise<void>,
|
||||||
className = 'animate-spin',
|
className = 'animate-spin',
|
||||||
) => {
|
) => {
|
||||||
let el = event.target as HTMLElement
|
let el = event.target as HTMLElement
|
||||||
@ -19,7 +19,7 @@ export const handlerBtnClickWithAnimate = async (
|
|||||||
|
|
||||||
el.classList.add(className)
|
el.classList.add(className)
|
||||||
try {
|
try {
|
||||||
await cb()
|
await callback()
|
||||||
} catch {}
|
} catch {}
|
||||||
el.classList.remove(className)
|
el.classList.remove(className)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
ProxyNodePreview,
|
ProxyNodePreview,
|
||||||
} from '~/components'
|
} from '~/components'
|
||||||
import {
|
import {
|
||||||
handlerBtnClickWithAnimate,
|
handleAnimatedBtnClickWithCallback,
|
||||||
sortProxiesByOrderingType,
|
sortProxiesByOrderingType,
|
||||||
} from '~/helpers'
|
} from '~/helpers'
|
||||||
import { proxiesOrderingType, useProxies } from '~/signals'
|
import { proxiesOrderingType, useProxies } from '~/signals'
|
||||||
@ -33,7 +33,7 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSpeedTestClick = (e: MouseEvent, name: string) => {
|
const onSpeedTestClick = (e: MouseEvent, name: string) => {
|
||||||
handlerBtnClickWithAnimate(
|
handleAnimatedBtnClickWithCallback(
|
||||||
e,
|
e,
|
||||||
latencyTestByProxyGroupName.bind(null, name),
|
latencyTestByProxyGroupName.bind(null, name),
|
||||||
'animate-pulse',
|
'animate-pulse',
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
} from '~/components'
|
} from '~/components'
|
||||||
import {
|
import {
|
||||||
formatTimeFromNow,
|
formatTimeFromNow,
|
||||||
handlerBtnClickWithAnimate,
|
handleAnimatedBtnClickWithCallback,
|
||||||
sortProxiesByOrderingType,
|
sortProxiesByOrderingType,
|
||||||
} from '~/helpers'
|
} from '~/helpers'
|
||||||
import { proxiesOrderingType, useProxies } from '~/signals'
|
import { proxiesOrderingType, useProxies } from '~/signals'
|
||||||
@ -31,7 +31,7 @@ export default () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onHealthCheckClick = (e: MouseEvent, name: string) => {
|
const onHealthCheckClick = (e: MouseEvent, name: string) => {
|
||||||
handlerBtnClickWithAnimate(
|
handleAnimatedBtnClickWithCallback(
|
||||||
e,
|
e,
|
||||||
healthCheckByProviderName.bind(null, name),
|
healthCheckByProviderName.bind(null, name),
|
||||||
'animate-pulse',
|
'animate-pulse',
|
||||||
@ -39,11 +39,14 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
||||||
handlerBtnClickWithAnimate(e, updateProviderByProviderName.bind(null, name))
|
handleAnimatedBtnClickWithCallback(
|
||||||
|
e,
|
||||||
|
updateProviderByProviderName.bind(null, name),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
||||||
handlerBtnClickWithAnimate(e, updateAllProvider)
|
handleAnimatedBtnClickWithCallback(e, updateAllProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -3,7 +3,10 @@ import { IconReload } from '@tabler/icons-solidjs'
|
|||||||
import InfiniteScroll from 'solid-infinite-scroll'
|
import InfiniteScroll from 'solid-infinite-scroll'
|
||||||
import { For, Show, createMemo, createSignal, onMount } from 'solid-js'
|
import { For, Show, createMemo, createSignal, onMount } from 'solid-js'
|
||||||
import { Button } from '~/components'
|
import { Button } from '~/components'
|
||||||
import { formatTimeFromNow, handlerBtnClickWithAnimate } from '~/helpers'
|
import {
|
||||||
|
formatTimeFromNow,
|
||||||
|
handleAnimatedBtnClickWithCallback,
|
||||||
|
} from '~/helpers'
|
||||||
import { useRules } from '~/signals'
|
import { useRules } from '~/signals'
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
@ -21,11 +24,14 @@ export default () => {
|
|||||||
onMount(updateRules)
|
onMount(updateRules)
|
||||||
|
|
||||||
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
||||||
handlerBtnClickWithAnimate(e, updateRuleProviderByName.bind(null, name))
|
handleAnimatedBtnClickWithCallback(
|
||||||
|
e,
|
||||||
|
updateRuleProviderByName.bind(null, name),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
||||||
handlerBtnClickWithAnimate(e, updateAllRuleProvider)
|
handleAnimatedBtnClickWithCallback(e, updateAllRuleProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user