feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -22,6 +22,7 @@ import { Link, useLocation } from 'react-router-dom';
|
||||
import { Dropdown } from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SkeletonWrapper from '../components/SkeletonWrapper';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
|
||||
const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
const location = useLocation();
|
||||
@@ -36,13 +37,8 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
const spacingClasses = isMobile ? 'px-2 py-1 text-sm' : 'px-4 py-2';
|
||||
|
||||
// Match on full path segments so /market doesn't light up on /market-detail
|
||||
const isPathActive = (matchPath) => {
|
||||
if (matchPath === '/') return location.pathname === '/';
|
||||
return (
|
||||
location.pathname === matchPath ||
|
||||
location.pathname.startsWith(`${matchPath}/`)
|
||||
);
|
||||
};
|
||||
const isPathActive = (matchPath) =>
|
||||
isNavigationPathActive(location.pathname, matchPath);
|
||||
|
||||
return mainNavLinks.map((link) => {
|
||||
const linkContent = <span className='relative z-10'>{link.text}</span>;
|
||||
@@ -58,7 +54,9 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
|
||||
// Check if active
|
||||
let isActive = false;
|
||||
if (link.items && link.items.length > 0) {
|
||||
if (link.activePrefix) {
|
||||
isActive = isPathActive(link.activePrefix);
|
||||
} else if (link.items && link.items.length > 0) {
|
||||
isActive = link.items.some((subItem) => isPathActive(subItem.to));
|
||||
} else if (!link.isExternal && targetPath) {
|
||||
isActive = isPathActive(link.activePrefix || targetPath);
|
||||
@@ -88,7 +86,10 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
>
|
||||
<div className={`${finalClasses} cursor-pointer`}>
|
||||
<div
|
||||
className={`${finalClasses} cursor-pointer`}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
>
|
||||
{linkContent}
|
||||
{/* Dropdown arrow */}
|
||||
<svg
|
||||
@@ -156,7 +157,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
className='ui-header-navigation flex flex-1 items-center gap-1 lg:gap-2 mx-1 sm:mx-3 md:mx-6 overflow-x-auto whitespace-nowrap scrollbar-hide min-w-0'
|
||||
>
|
||||
<SkeletonWrapper
|
||||
loading={isLoading}
|
||||
loading={isLoading && mainNavLinks.length === 0}
|
||||
type='navigation'
|
||||
count={4}
|
||||
width={60}
|
||||
|
||||
Reference in New Issue
Block a user