diff --git a/src/custom-tab-bar/index.tsx b/src/custom-tab-bar/index.tsx index c642196..d31332e 100644 --- a/src/custom-tab-bar/index.tsx +++ b/src/custom-tab-bar/index.tsx @@ -11,6 +11,7 @@ import { useSelector } from '@/reducers/hooks' import { TabBarType } from '@/constants/tabbar' import type { TabBarAction } from '@/reducers/tabBar' import { UseSubscriptionMessage } from '@/use/useCommon' +import { debounce } from '@/common/util' type IconfontName = Parameters['0']['name'] @@ -41,16 +42,14 @@ const CustomTabBar: FC = () => { const setSelected = (id: TabBarIndexMap[number]['id']) => { dispatch({ type: TabBarType.SET_SELECTED, data: { tabItem, selectedId: id } }) } - const handleSelectTabItem = (id: TabBarIndexMap[number]['id']) => { - return async() => { - setSelected(id) - if (id === 3) { - await openSubscriptionMessage({ scenes: 1 }) - } - console.log(id, 'item') - Taro.switchTab({ url: tabItem?.find(item => item.id === id)?.pagePath as string }) + const handleSelectTabItem = debounce(async(id: TabBarIndexMap[number]['id']) => { + setSelected(id) + if (id === 3) { + await openSubscriptionMessage({ scenes: 1 }) } - } + console.log(id, 'item') + Taro.switchTab({ url: tabItem?.find(item => item.id === id)?.pagePath as string }) + }, 300) return ( @@ -60,7 +59,7 @@ const CustomTabBar: FC = () => { handleSelectTabItem(item.id)} >