fix(ui): 统一下载页主题与智能路由页签间距
This commit is contained in:
@@ -19,8 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import { Globe as ActionGlobe } from '@/components/common/icons/ActionIcons';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button as AntButton } from 'antd';
|
||||
import { Dropdown } from '@/components/ui';
|
||||
import { Button as AntButton, Dropdown } from 'antd';
|
||||
import { CN, GB, JP, KR, TH, VN } from 'country-flag-icons/react/3x2';
|
||||
import { normalizeLanguage } from '../../../i18n/language';
|
||||
import { orderEnabledLanguages } from '../../../i18n/catalog';
|
||||
@@ -47,41 +46,32 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
|
||||
window.removeEventListener(LANG_BOOT_UPDATED_EVENT, handleBootUpdated);
|
||||
}, []);
|
||||
|
||||
const getItemClassName = (isSelected) =>
|
||||
`!flex !items-center !gap-2 !px-3 !py-1.5 !text-sm ${
|
||||
isSelected
|
||||
? '!bg-ui-color-primary-light-default !font-semibold'
|
||||
: 'hover:!bg-ui-color-fill-1'
|
||||
}`;
|
||||
|
||||
// 展示哪些语言、按什么顺序由后台「语言与地区」配置决定(经 /api/i18n/locale 缓存下发)
|
||||
const languages = orderEnabledLanguages(getBootConfig()?.enabled_languages);
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
position='bottomRight'
|
||||
render={
|
||||
<Dropdown.Menu>
|
||||
{languages.map(({ code, endonym, flag }) => {
|
||||
const Flag = FLAGS[flag];
|
||||
return (
|
||||
<Dropdown.Item
|
||||
key={code}
|
||||
onClick={() => onLanguageChange(code)}
|
||||
className={getItemClassName(lang === code)}
|
||||
>
|
||||
{Flag && <Flag title={endonym} className='!w-5 !h-auto' />}
|
||||
<span>{endonym}</span>
|
||||
</Dropdown.Item>
|
||||
);
|
||||
})}
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
trigger={['hover', 'click']}
|
||||
placement='bottomRight'
|
||||
menu={{
|
||||
selectable: true,
|
||||
selectedKeys: [lang],
|
||||
onClick: ({ key }) => onLanguageChange(key),
|
||||
items: languages.map(({ code, endonym, flag }) => {
|
||||
const Flag = FLAGS[flag];
|
||||
return {
|
||||
key: code,
|
||||
icon: Flag ? <Flag title={endonym} className='w-5 h-auto' /> : null,
|
||||
label: endonym,
|
||||
};
|
||||
}),
|
||||
}}
|
||||
>
|
||||
<AntButton
|
||||
type='text'
|
||||
icon={<ActionGlobe size={16} strokeWidth={1.5} aria-hidden />}
|
||||
aria-label={t('common.changeLanguage')}
|
||||
aria-haspopup='menu'
|
||||
className='ui-header-icon-action'
|
||||
/>
|
||||
</Dropdown>
|
||||
|
||||
@@ -20,7 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import { Compass as ActionCompass } from '@/components/common/icons/ActionIcons';
|
||||
import React, { useState } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { Button, Dropdown } from '@/components/ui';
|
||||
import { Button, Dropdown } from 'antd';
|
||||
import { ExternalLink } from 'lucide-react';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
|
||||
@@ -92,63 +92,51 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomLeft'
|
||||
visible={visible}
|
||||
onVisibleChange={setVisible}
|
||||
render={
|
||||
<Dropdown.Menu className='!min-w-[168px] !p-1.5 !rounded-xl !border !border-gray-100 dark:!border-neutral-800 !shadow-xl !shadow-gray-200/50 dark:!shadow-black/30 !backdrop-blur-xl !bg-white/95 dark:!bg-neutral-900/95'>
|
||||
{menuItems.map((item) => (
|
||||
<Dropdown.Item
|
||||
key={item.key}
|
||||
onClick={() => {
|
||||
setVisible(false);
|
||||
if (item.externalLink) {
|
||||
window.open(
|
||||
item.externalLink,
|
||||
'_blank',
|
||||
'noopener,noreferrer',
|
||||
);
|
||||
} else if (item.to) {
|
||||
navigate(item.to);
|
||||
}
|
||||
}}
|
||||
className={`!rounded-lg !my-0.5 !px-3 !py-2 !text-sm !transition-colors ${
|
||||
item.active
|
||||
? '!bg-brand/10 dark:!bg-brand-deep/40 !text-brand-deep dark:!text-brand-from !font-semibold'
|
||||
: '!text-gray-700 dark:!text-neutral-200'
|
||||
}`}
|
||||
trigger={['click']}
|
||||
placement='bottomLeft'
|
||||
open={visible}
|
||||
onOpenChange={setVisible}
|
||||
menu={{
|
||||
selectedKeys: menuItems
|
||||
.filter((item) => item.active)
|
||||
.map((item) => item.key),
|
||||
items: menuItems.map((item) => ({
|
||||
key: item.key,
|
||||
onClick: () => {
|
||||
setVisible(false);
|
||||
if (item.externalLink) {
|
||||
window.open(item.externalLink, '_blank', 'noopener,noreferrer');
|
||||
} else if (item.to) {
|
||||
navigate(item.to);
|
||||
}
|
||||
},
|
||||
label: (
|
||||
<span
|
||||
className='flex items-center gap-1.5'
|
||||
aria-current={item.active ? 'page' : undefined}
|
||||
>
|
||||
<span
|
||||
className='flex items-center gap-1.5'
|
||||
aria-current={item.active ? 'page' : undefined}
|
||||
>
|
||||
{item.text}
|
||||
{item.externalLink && (
|
||||
<ExternalLink size={12} className='opacity-50' />
|
||||
)}
|
||||
</span>
|
||||
</Dropdown.Item>
|
||||
))}
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
{item.text}
|
||||
{item.externalLink && (
|
||||
<ExternalLink size={12} className='opacity-50' />
|
||||
)}
|
||||
</span>
|
||||
),
|
||||
})),
|
||||
}}
|
||||
>
|
||||
<span className='inline-flex'>
|
||||
<Button
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
aria-label={t('主导航')}
|
||||
title={activeItem?.text}
|
||||
aria-haspopup='menu'
|
||||
aria-expanded={visible}
|
||||
icon={<ActionCompass size={16} />}
|
||||
className='!ml-1 !px-2 !h-8 max-w-[9rem] !rounded-xl !text-current hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-all !duration-200 active:!scale-95 [&_.ant-btn-content]:min-w-0'
|
||||
>
|
||||
<span className='ml-1 text-[13px] font-semibold truncate'>
|
||||
{activeItem?.mobileText || activeItem?.text || t('导航')}
|
||||
</span>
|
||||
</Button>
|
||||
</span>
|
||||
<Button
|
||||
type='text'
|
||||
aria-label={t('主导航')}
|
||||
title={activeItem?.text}
|
||||
aria-haspopup='menu'
|
||||
aria-expanded={visible}
|
||||
icon={<ActionCompass size={16} />}
|
||||
className='ml-1 px-2 max-w-[9rem] [&_.ant-btn-content]:min-w-0'
|
||||
>
|
||||
<span className='ml-1 text-[13px] font-semibold truncate'>
|
||||
{activeItem?.mobileText || activeItem?.text || t('导航')}
|
||||
</span>
|
||||
</Button>
|
||||
</Dropdown>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -19,7 +19,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { Dropdown } from '@/components/ui';
|
||||
import { Dropdown } from 'antd';
|
||||
import {
|
||||
ChevronDown,
|
||||
ExternalLink,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SkeletonWrapper from '../components/SkeletonWrapper';
|
||||
import { isNavigationPathActive } from '../../console/consoleRoutes';
|
||||
@@ -68,44 +72,27 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
return (
|
||||
<Dropdown
|
||||
key={link.itemKey}
|
||||
trigger={'hover'}
|
||||
position={'bottomLeft'}
|
||||
render={
|
||||
<Dropdown.Menu>
|
||||
{link.items.map((subItem) => (
|
||||
<Dropdown.Item key={subItem.itemKey}>
|
||||
<Link
|
||||
to={subItem.to}
|
||||
className='block w-full py-0.5 text-gray-700 dark:text-neutral-200 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
{subItem.text}
|
||||
</Link>
|
||||
</Dropdown.Item>
|
||||
))}
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
trigger={['hover', 'click']}
|
||||
placement='bottomLeft'
|
||||
menu={{
|
||||
selectedKeys: link.items
|
||||
.filter((item) => isPathActive(item.to))
|
||||
.map((item) => item.itemKey),
|
||||
items: link.items.map((subItem) => ({
|
||||
key: subItem.itemKey,
|
||||
label: <Link to={subItem.to}>{subItem.text}</Link>,
|
||||
})),
|
||||
}}
|
||||
>
|
||||
<div
|
||||
<button
|
||||
type='button'
|
||||
className={`${finalClasses} cursor-pointer`}
|
||||
aria-haspopup='menu'
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
>
|
||||
{linkContent}
|
||||
{/* Dropdown arrow */}
|
||||
<svg
|
||||
className='w-3.5 h-3.5 opacity-50 group-hover:opacity-100 transition-all duration-300 group-hover:rotate-180'
|
||||
fill='none'
|
||||
viewBox='0 0 24 24'
|
||||
stroke='currentColor'
|
||||
>
|
||||
<path
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
strokeWidth={2}
|
||||
d='M19 9l-7 7-7-7'
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<ChevronDown size={14} aria-hidden />
|
||||
</button>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
@@ -120,20 +107,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
|
||||
className={`${baseClasses} ${spacingClasses} ${defaultClasses} ${hoverClasses}`}
|
||||
>
|
||||
{linkContent}
|
||||
{/* External link icon */}
|
||||
<svg
|
||||
className='w-3 h-3 opacity-50 group-hover:opacity-100 transition-opacity'
|
||||
fill='none'
|
||||
viewBox='0 0 24 24'
|
||||
stroke='currentColor'
|
||||
>
|
||||
<path
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
strokeWidth={2}
|
||||
d='M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'
|
||||
/>
|
||||
</svg>
|
||||
<ExternalLink size={12} aria-hidden />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ const UserArea = ({
|
||||
|
||||
return (
|
||||
<AntDropdown
|
||||
trigger={['hover']}
|
||||
trigger={['hover', 'click']}
|
||||
placement='bottomRight'
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
|
||||
Reference in New Issue
Block a user