mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-23 21:35:36 +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()
|
||||
}
|
||||
|
||||
export const handlerBtnClickWithAnimate = async (
|
||||
export const handleAnimatedBtnClickWithCallback = async (
|
||||
event: MouseEvent,
|
||||
cb: () => void,
|
||||
callback: () => Promise<void>,
|
||||
className = 'animate-spin',
|
||||
) => {
|
||||
let el = event.target as HTMLElement
|
||||
@ -19,7 +19,7 @@ export const handlerBtnClickWithAnimate = async (
|
||||
|
||||
el.classList.add(className)
|
||||
try {
|
||||
await cb()
|
||||
await callback()
|
||||
} catch {}
|
||||
el.classList.remove(className)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
ProxyNodePreview,
|
||||
} from '~/components'
|
||||
import {
|
||||
handlerBtnClickWithAnimate,
|
||||
handleAnimatedBtnClickWithCallback,
|
||||
sortProxiesByOrderingType,
|
||||
} from '~/helpers'
|
||||
import { proxiesOrderingType, useProxies } from '~/signals'
|
||||
@ -33,7 +33,7 @@ export default () => {
|
||||
}
|
||||
|
||||
const onSpeedTestClick = (e: MouseEvent, name: string) => {
|
||||
handlerBtnClickWithAnimate(
|
||||
handleAnimatedBtnClickWithCallback(
|
||||
e,
|
||||
latencyTestByProxyGroupName.bind(null, name),
|
||||
'animate-pulse',
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
} from '~/components'
|
||||
import {
|
||||
formatTimeFromNow,
|
||||
handlerBtnClickWithAnimate,
|
||||
handleAnimatedBtnClickWithCallback,
|
||||
sortProxiesByOrderingType,
|
||||
} from '~/helpers'
|
||||
import { proxiesOrderingType, useProxies } from '~/signals'
|
||||
@ -31,7 +31,7 @@ export default () => {
|
||||
)
|
||||
|
||||
const onHealthCheckClick = (e: MouseEvent, name: string) => {
|
||||
handlerBtnClickWithAnimate(
|
||||
handleAnimatedBtnClickWithCallback(
|
||||
e,
|
||||
healthCheckByProviderName.bind(null, name),
|
||||
'animate-pulse',
|
||||
@ -39,11 +39,14 @@ export default () => {
|
||||
}
|
||||
|
||||
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
||||
handlerBtnClickWithAnimate(e, updateProviderByProviderName.bind(null, name))
|
||||
handleAnimatedBtnClickWithCallback(
|
||||
e,
|
||||
updateProviderByProviderName.bind(null, name),
|
||||
)
|
||||
}
|
||||
|
||||
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
||||
handlerBtnClickWithAnimate(e, updateAllProvider)
|
||||
handleAnimatedBtnClickWithCallback(e, updateAllProvider)
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -3,7 +3,10 @@ import { IconReload } from '@tabler/icons-solidjs'
|
||||
import InfiniteScroll from 'solid-infinite-scroll'
|
||||
import { For, Show, createMemo, createSignal, onMount } from 'solid-js'
|
||||
import { Button } from '~/components'
|
||||
import { formatTimeFromNow, handlerBtnClickWithAnimate } from '~/helpers'
|
||||
import {
|
||||
formatTimeFromNow,
|
||||
handleAnimatedBtnClickWithCallback,
|
||||
} from '~/helpers'
|
||||
import { useRules } from '~/signals'
|
||||
|
||||
export default () => {
|
||||
@ -21,11 +24,14 @@ export default () => {
|
||||
onMount(updateRules)
|
||||
|
||||
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
||||
handlerBtnClickWithAnimate(e, updateRuleProviderByName.bind(null, name))
|
||||
handleAnimatedBtnClickWithCallback(
|
||||
e,
|
||||
updateRuleProviderByName.bind(null, name),
|
||||
)
|
||||
}
|
||||
|
||||
const onUpdateAllProviderClick = (e: MouseEvent) => {
|
||||
handlerBtnClickWithAnimate(e, updateAllRuleProvider)
|
||||
handleAnimatedBtnClickWithCallback(e, updateAllRuleProvider)
|
||||
}
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user