From 891a1ad22fdca6bf9ea2433377afd2a0e438c72f Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 24 十月 2025 15:48:18 +0800
Subject: [PATCH] fix: bug
---
apps/cMiniApp/src/custom-tab-bar/index.tsx | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/apps/cMiniApp/src/custom-tab-bar/index.tsx b/apps/cMiniApp/src/custom-tab-bar/index.tsx
index 1645110..44fb564 100644
--- a/apps/cMiniApp/src/custom-tab-bar/index.tsx
+++ b/apps/cMiniApp/src/custom-tab-bar/index.tsx
@@ -15,6 +15,7 @@
icon: string;
activeIcon: string;
pagePath: string;
+ currentPath: string;
active: boolean;
className: string;
onClick?: (url: string, index: number) => any;
@@ -28,14 +29,16 @@
const TarBarItem = function (props: TarBarItemProps, context: SetupContext<TarBarItemEvents>) {
const _badge = props.badge > 99 ? '99+' : props.badge;
+ // const isActive = props.currentPath.toLowerCase().includes(props.pagePath.toLowerCase());
+ const isActive = props.active;
return (
<div
- class={['bottom-tab-item', { active: props.active }, props.className]}
+ class={['bottom-tab-item', { active: isActive }, props.className]}
onClick={() => context.emit('click', props.pagePath, props.index)}
>
<div class="bottom-tab-item-icon-wrapper">
{props.badge > 0 && <div class="bottom-tab-item-badge">{_badge}</div>}
- <img class="bottom-tab-item-icon" src={props.active ? props.activeIcon : props.icon} />
+ <img class="bottom-tab-item-icon" src={isActive ? props.activeIcon : props.icon} />
</div>
<div class="bottom-tab-item-text">{props.text}</div>
</div>
@@ -65,8 +68,10 @@
const isLogin = useIsLogin();
const loginTipShowed = ref(false);
+ const isClicking = ref(false);
const switchTab = (url: string, index: number) => {
+ if (isClicking.value) return;
if (!isLogin.value && whitePageList.every((x) => x !== url)) {
if (!loginTipShowed.value) {
loginTipShowed.value = true;
@@ -82,8 +87,14 @@
}
return;
}
- system.setTabIndex(index);
- Taro.switchTab({ url });
+ isClicking.value = true;
+ Taro.switchTab({ url })
+ .then(() => {
+ system.setTabIndex(index);
+ })
+ .finally(() => {
+ isClicking.value = false;
+ });
};
function goPublish() {
@@ -109,6 +120,7 @@
}
return () => {
+ const _router = Taro.useRouter();
return (
<View
class="bottom-tab"
@@ -121,6 +133,7 @@
icon="../assets/tabbar/icon-home.png"
activeIcon="../assets/tabbar/icon-home-active.png"
pagePath={TabBarPageRouter.Home}
+ currentPath={_router.path}
index={0}
active={system.activeTab === 0}
className="home"
@@ -132,6 +145,7 @@
icon="../assets/tabbar/icon-task.png"
activeIcon="../assets/tabbar/icon-task-active.png"
pagePath={TabBarPageRouter.Task}
+ currentPath={_router.path}
active={system.activeTab === 1}
className="task"
onClick={switchTab}
@@ -142,6 +156,7 @@
icon="../assets/tabbar/icon-mine.png"
activeIcon="../assets/tabbar/icon-mine-active.png"
pagePath={TabBarPageRouter.Mine}
+ currentPath={_router.path}
active={system.activeTab === 2}
className="mine"
onClick={switchTab}
--
Gitblit v1.9.1