feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -21,6 +21,7 @@ import React, { useState } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { Button, Dropdown } from '@/components/ui';
|
||||
import { Compass, ExternalLink } from 'lucide-react';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
|
||||
/**
|
||||
* 移动端主导航入口。
|
||||
@@ -41,14 +42,8 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
||||
}
|
||||
|
||||
// 与 Navigation 一致:按完整路径段匹配,避免 /market 命中 /market-detail
|
||||
const isPathActive = (matchPath) => {
|
||||
if (!matchPath) return false;
|
||||
if (matchPath === '/') return location.pathname === '/';
|
||||
return (
|
||||
location.pathname === matchPath ||
|
||||
location.pathname.startsWith(`${matchPath}/`)
|
||||
);
|
||||
};
|
||||
const isPathActive = (matchPath) =>
|
||||
isNavigationPathActive(location.pathname, matchPath);
|
||||
|
||||
// 与 Navigation 一致:未登录时需要鉴权的入口统一引导到企业登录
|
||||
const resolveTarget = (link) => {
|
||||
@@ -122,7 +117,10 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
||||
: '!text-gray-700 dark:!text-neutral-200'
|
||||
}`}
|
||||
>
|
||||
<span className='flex items-center gap-1.5'>
|
||||
<span
|
||||
className='flex items-center gap-1.5'
|
||||
aria-current={item.active ? 'page' : undefined}
|
||||
>
|
||||
{item.text}
|
||||
{item.externalLink && (
|
||||
<ExternalLink size={12} className='opacity-50' />
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -147,13 +147,15 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
||||
/>
|
||||
|
||||
{/* 移动端:主导航收进下拉菜单,避免与右侧操作区互相挤压 */}
|
||||
{!isAuthPage && isMobile && !isLoading && (
|
||||
<MobileNavMenu
|
||||
mainNavLinks={mainNavLinks}
|
||||
userState={userState}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
{!isAuthPage &&
|
||||
isMobile &&
|
||||
(!isLoading || mainNavLinks.length > 0) && (
|
||||
<MobileNavMenu
|
||||
mainNavLinks={mainNavLinks}
|
||||
userState={userState}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!isAuthPage && !isMobile && (
|
||||
|
||||
Reference in New Issue
Block a user