fix(mp): 医生端添加底部导航栏解决无法退出登录问题
医生端工作台是分包页面,不在 TabBar 配置中,redirectTo 后底部 导航消失导致无法到达"我的"页面退出登录。新增 DoctorTabBar 组件 模拟底部导航,包含工作台/患者/咨询/我的四个入口,使用 reLaunch 切换避免页栈溢出。
This commit is contained in:
47
apps/miniprogram/src/components/ui/DoctorTabBar/index.tsx
Normal file
47
apps/miniprogram/src/components/ui/DoctorTabBar/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import './index.scss';
|
||||
|
||||
interface TabItem {
|
||||
key: string;
|
||||
icon: string;
|
||||
activeIcon: string;
|
||||
label: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
const DOCTOR_TABS: TabItem[] = [
|
||||
{ key: 'workbench', icon: '🏠', activeIcon: '🏠', label: '工作台', url: '/pages/pkg-doctor-core/index' },
|
||||
{ key: 'patients', icon: '👤', activeIcon: '👤', label: '患者', url: '/pages/pkg-doctor-core/patients/index' },
|
||||
{ key: 'consultation', icon: '💬', activeIcon: '💬', label: '咨询', url: '/pages/pkg-doctor-core/consultation/index' },
|
||||
{ key: 'settings', icon: '⚙️', activeIcon: '⚙️', label: '我的', url: '/pages/pkg-profile/settings/index' },
|
||||
];
|
||||
|
||||
interface DoctorTabBarProps {
|
||||
active?: string;
|
||||
}
|
||||
|
||||
export default function DoctorTabBar({ active }: DoctorTabBarProps) {
|
||||
const currentPath = `/${Taro.getCurrentPages().pop()?.path ?? ''}`;
|
||||
const activeKey = active ?? DOCTOR_TABS.find((t) => currentPath.startsWith(t.url.replace('/index', '')))?.key ?? 'workbench';
|
||||
|
||||
const handleTab = (tab: TabItem) => {
|
||||
if (tab.key === activeKey) return;
|
||||
Taro.reLaunch({ url: tab.url });
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="doctor-tabbar">
|
||||
{DOCTOR_TABS.map((tab) => (
|
||||
<View
|
||||
key={tab.key}
|
||||
className={`doctor-tabbar__item ${tab.key === activeKey ? 'doctor-tabbar__item--active' : ''}`}
|
||||
onClick={() => handleTab(tab)}
|
||||
>
|
||||
<Text className="doctor-tabbar__icon">{tab.key === activeKey ? tab.activeIcon : tab.icon}</Text>
|
||||
<Text className="doctor-tabbar__label">{tab.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user