From 0e795563c065721976e812f37d5409489d8b198a Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Thu, 25 Dec 2025 13:57:18 +0800 Subject: [PATCH] =?UTF-8?q?perf(Navbar):=20=E7=A7=BB=E9=99=A4=E8=87=AA?= =?UTF-8?q?=E9=80=89=E8=82=A1/=E4=BA=8B=E4=BB=B6=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E6=B8=85=E7=90=86=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NavbarActions: - 移除 WatchlistMenu 和 FollowingEventsMenu 组件 - 移除 watchlistQuotes/followingEvents props HomeNavbar: - 移除 useWatchlist/useFollowingEvents hooks 调用 - 移除相关导入和 props 传递 TabletUserMenu: - 移除 watchlistQuotes/followingEvents props - 简化菜单项(移除数量 Badge) 性能提升: - 减少 2 个 hook 初始化和 4+ 个 Redux selector 订阅 - 减少导航栏初始化时的 API 请求 - 侧边工具栏不受影响(有独立的 GlobalSidebarContext) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/Navbars/HomeNavbar.js | 12 ----------- .../Navbars/components/NavbarActions/index.js | 15 +------------ .../components/UserMenu/TabletUserMenu.js | 21 +++---------------- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/components/Navbars/HomeNavbar.js b/src/components/Navbars/HomeNavbar.js index d52ecc20..63d37692 100644 --- a/src/components/Navbars/HomeNavbar.js +++ b/src/components/Navbars/HomeNavbar.js @@ -44,11 +44,6 @@ import { DesktopNav, MoreMenu, PersonalCenterMenu } from './components/Navigatio // Phase 5 优化: 提取的移动端抽屉菜单组件 import { MobileDrawer } from './components/MobileDrawer'; -// Phase 6 优化: 提取的功能菜单组件和自定义 Hooks -import { WatchlistMenu, FollowingEventsMenu } from './components/FeatureMenus'; -import { useWatchlist } from '../../hooks/useWatchlist'; -import { useFollowingEvents } from '../../hooks/useFollowingEvents'; - // Phase 7 优化: 提取的资料完整性、右侧功能区组件 import ProfileCompletenessAlert from './components/ProfileCompletenessAlert'; import { useProfileCompleteness } from '../../hooks/useProfileCompleteness'; @@ -96,11 +91,6 @@ export default function HomeNavbar() { return user.nickname || user.username || user.name || user.email || '用户'; }; - // Phase 6: 自选股和关注事件逻辑已提取到自定义 Hooks - const { watchlistQuotes, followingEvents } = useWatchlist(); - const { followingEvents: events } = useFollowingEvents(); - // 注意:这里只需要数据用于 TabletUserMenu,实际的菜单组件会自己管理状态 - // Phase 7: 资料完整性逻辑已提取到 useProfileCompleteness Hook const { profileCompleteness, @@ -174,8 +164,6 @@ export default function HomeNavbar() { isMobile={isMobile} onMenuOpen={onOpen} handleLogout={handleLogout} - watchlistQuotes={watchlistQuotes} - followingEvents={followingEvents} /> diff --git a/src/components/Navbars/components/NavbarActions/index.js b/src/components/Navbars/components/NavbarActions/index.js index 0e804f1a..0994252b 100644 --- a/src/components/Navbars/components/NavbarActions/index.js +++ b/src/components/Navbars/components/NavbarActions/index.js @@ -7,7 +7,6 @@ import { Menu } from 'lucide-react'; // import ThemeToggleButton from '../ThemeToggleButton'; // ❌ 已删除 - 不再支持深色模式切换 import LoginButton from '../LoginButton'; import CalendarButton from '../CalendarButton'; -import { WatchlistMenu, FollowingEventsMenu } from '../FeatureMenus'; import { DesktopUserMenu, TabletUserMenu } from '../UserMenu'; import { PersonalCenterMenu, MoreMenu } from '../Navigation'; @@ -24,8 +23,6 @@ import { PersonalCenterMenu, MoreMenu } from '../Navigation'; * @param {boolean} props.isMobile - 是否为移动端 * @param {Function} props.onMenuOpen - 打开移动端抽屉菜单的回调 * @param {Function} props.handleLogout - 登出回调 - * @param {Array} props.watchlistQuotes - 自选股数据(用于 TabletUserMenu) - * @param {Array} props.followingEvents - 关注事件数据(用于 TabletUserMenu) */ const NavbarActions = memo(({ isLoading, @@ -35,9 +32,7 @@ const NavbarActions = memo(({ isTablet, isMobile, onMenuOpen, - handleLogout, - watchlistQuotes, - followingEvents + handleLogout }) => { return ( @@ -56,12 +51,6 @@ const NavbarActions = memo(({ {/* 投资日历 - 仅大屏显示 */} {isDesktop && } - {/* 自选股 - 仅大屏显示 */} - {isDesktop && } - - {/* 关注的事件 - 仅大屏显示 */} - {isDesktop && } - {/* 头像区域 - 响应式 */} {isDesktop ? ( @@ -69,8 +58,6 @@ const NavbarActions = memo(({ )} diff --git a/src/components/Navbars/components/UserMenu/TabletUserMenu.js b/src/components/Navbars/components/UserMenu/TabletUserMenu.js index 9cca6165..70f1d032 100644 --- a/src/components/Navbars/components/UserMenu/TabletUserMenu.js +++ b/src/components/Navbars/components/UserMenu/TabletUserMenu.js @@ -11,7 +11,6 @@ import { Box, Text, Badge, - Flex, useColorModeValue } from '@chakra-ui/react'; import { Star, Calendar, User, Settings, Home, LogOut, Crown } from 'lucide-react'; @@ -26,14 +25,10 @@ import { useSubscription } from '../../../../hooks/useSubscription'; * @param {Object} props * @param {Object} props.user - 用户信息 * @param {Function} props.handleLogout - 退出登录回调 - * @param {Array} props.watchlistQuotes - 自选股列表 - * @param {Array} props.followingEvents - 自选事件列表 */ const TabletUserMenu = memo(({ user, - handleLogout, - watchlistQuotes, - followingEvents + handleLogout }) => { const navigate = useNavigate(); const { subscriptionInfo } = useSubscription(); @@ -101,22 +96,12 @@ const TabletUserMenu = memo(({ {/* 自选股 */} } onClick={() => navigate('/home/center')}> - - 我的自选股 - {watchlistQuotes && watchlistQuotes.length > 0 && ( - {watchlistQuotes.length} - )} - + 我的自选股 {/* 自选事件 */} } onClick={() => navigate('/home/center')}> - - 我的自选事件 - {followingEvents && followingEvents.length > 0 && ( - {followingEvents.length} - )} - + 我的自选事件