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>
|
||||
|
||||
Reference in New Issue
Block a user