feat(導航組件優化): 移除NavCommon組件中的冗餘onMenuClick屬性,並優化菜單圖標點擊邏輯以實現路由切換,提升用戶體驗。

This commit is contained in:
超级老白兔
2025-09-23 19:15:31 +08:00
parent 424fc518ff
commit c32ff2cf29

View File

@@ -23,10 +23,7 @@ interface NavCommonProps {
onMenuClick?: () => void;
}
const NavCommon: React.FC<NavCommonProps> = ({
title = "触客宝",
onMenuClick,
}) => {
const NavCommon: React.FC<NavCommonProps> = ({ title = "触客宝" }) => {
const [drawerVisible, setDrawerVisible] = useState(false);
const [messageDrawerVisible, setMessageDrawerVisible] = useState(false);
const [messageCount] = useState(3); // 模拟消息数量
@@ -34,10 +31,14 @@ const NavCommon: React.FC<NavCommonProps> = ({
const location = useLocation();
const { user, logout } = useUserStore();
// 处理菜单图标点击
// 处理菜单图标点击:在两个路由之间切换
const handleMenuClick = () => {
setDrawerVisible(true);
onMenuClick?.();
const current = location.pathname;
if (current.startsWith("/pc/powerCenter")) {
navigate("/pc/weChat");
} else {
navigate("/pc/powerCenter");
}
};
// 处理抽屉关闭