diff --git a/src/components/Navbars/HomeNavbar.js b/src/components/Navbars/HomeNavbar.js index 9e81281c..671bc2d8 100644 --- a/src/components/Navbars/HomeNavbar.js +++ b/src/components/Navbars/HomeNavbar.js @@ -31,6 +31,7 @@ import { useColorMode, useColorModeValue, useToast, + Tooltip, } from '@chakra-ui/react'; import { ChevronDownIcon, HamburgerIcon, SunIcon, MoonIcon } from '@chakra-ui/icons'; import { FiStar, FiCalendar, FiUser, FiSettings, FiHome, FiLogOut } from 'react-icons/fi'; @@ -42,6 +43,7 @@ import { logger } from '../../utils/logger'; import { getApiBase } from '../../utils/apiConfig'; import SubscriptionButton from '../Subscription/SubscriptionButton'; import SubscriptionModal from '../Subscription/SubscriptionModal'; +import CrownTooltip, { TooltipContent } from '../Subscription/CrownTooltip'; /** 二级导航栏组件 - 显示当前一级菜单下的所有二级菜单项 */ const SecondaryNav = ({ showCompletenessAlert }) => { @@ -669,44 +671,46 @@ export default function HomeNavbar() { - - - - - + + + + + 完善资料,享受更好服务 - + 您还需要设置:{profileCompleteness.missingItems.join('、')} - + {profileCompleteness.completenessPercentage}% 完成 - + ×} + icon={×} onClick={() => setShowCompletenessAlert(false)} aria-label="关闭提醒" + minW={{ base: '32px', md: '40px' }} /> @@ -722,20 +726,21 @@ export default function HomeNavbar() { backdropFilter="blur(10px)" borderBottom="1px" borderColor={navbarBorder} - py={3} + py={{ base: 2, md: 3 }} > - + {/* Logo - 价小前投研 */} - + navigate('/home')} - style={{ minWidth: '140px' }} + style={{ minWidth: isMobile ? '100px' : '140px' }} + noOfLines={1} > 价小前投研 @@ -752,13 +757,15 @@ export default function HomeNavbar() { ) : } {/* 右侧:日夜模式切换 + 登录/用户区 */} - + : } onClick={toggleColorMode} variant="ghost" size="sm" + minW={{ base: '36px', md: '40px' }} + minH={{ base: '36px', md: '40px' }} /> {/* 显示加载状态 */} @@ -766,95 +773,9 @@ export default function HomeNavbar() { ) : isAuthenticated && user ? ( // 已登录状态 - 用户菜单 + 功能菜单排列 - - {/* 用户头像+订阅徽章组合 */} - - {/* 用户头像菜单 */} - - - } - bg="transparent" - _hover={{ bg: useColorModeValue('gray.100', 'gray.700') }} - borderRadius="full" - position="relative" - aria-label="用户菜单" - > - - - - {getDisplayName()} - {user.email} - {user.phone && ( - {user.phone} - )} - {user.has_wechat && ( - 微信已绑定 - )} - - {/* 账户管理组 */} - } onClick={() => navigate('/home/profile')}> - 个人资料 - - } onClick={() => navigate('/home/settings')}> - 账户设置 - - - {/* 功能入口组 */} - } onClick={() => navigate('/home/pages/account/subscription')}> - 订阅管理 - - - {/* 退出 */} - } onClick={handleLogout} color="red.500"> - 退出登录 - - - - - {/* 订阅徽章按钮 - 点击打开订阅弹窗 */} - setIsSubscriptionModalOpen(true)} - /> - - {/* 订阅管理弹窗 - 只在打开时渲染 */} - {isSubscriptionModalOpen && ( - setIsSubscriptionModalOpen(false)} - subscriptionInfo={subscriptionInfo} - /> - )} - - - {/* 个人中心快捷按钮 */} - } - size="sm" - colorScheme="gray" - variant="ghost" - onClick={() => navigate('/home/center')} - aria-label="个人中心" - _hover={{ bg: 'gray.700' }} - /> - - {/* 自选股 - 头像右侧 */} + + {/* 自选股 - 移动端隐藏 */} + {!isMobile && ( + )} - {/* 关注的事件 - 头像右侧 */} + {/* 关注的事件 - 头像右侧 - 移动端隐藏 */} + {!isMobile && ( + )} + + {/* 带会员标识的头像 - 点击打开订阅弹窗 */} + setIsSubscriptionModalOpen(true)} + > + {/* 会员图标徽章 - 使用独立的 CrownTooltip 组件 */} + + + {/* 头像 - 带会员等级边框和详细信息 Tooltip */} + } + placement="bottom" + hasArrow + bg={useColorModeValue('white', 'gray.800')} + borderRadius="lg" + border="1px solid" + borderColor={useColorModeValue('gray.200', 'gray.600')} + boxShadow="lg" + p={3} + > + + + + + {/* 订阅管理弹窗 - 只在打开时渲染 */} + {isSubscriptionModalOpen && ( + setIsSubscriptionModalOpen(false)} + subscriptionInfo={subscriptionInfo} + /> + )} + + {/* 个人中心下拉菜单 */} + + } + _hover={{ bg: useColorModeValue('gray.100', 'gray.700') }} + > + 个人中心 + + + + {getDisplayName()} + {user.email} + {user.phone && ( + {user.phone} + )} + {user.has_wechat && ( + 微信已绑定 + )} + + {/* 前往个人中心 */} + } onClick={() => navigate('/home/center')}> + 前往个人中心 + + + {/* 账户管理组 */} + } onClick={() => navigate('/home/profile')}> + 个人资料 + + } onClick={() => navigate('/home/settings')}> + 账户设置 + + + {/* 功能入口组 */} + } onClick={() => navigate('/home/pages/account/subscription')}> + 订阅管理 + + + {/* 退出 */} + } onClick={handleLogout} color="red.500"> + 退出登录 + + + ) : ( // 未登录状态 - 单一按钮