feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent 1fd4e084b6
commit 15192c433b
576 changed files with 18075 additions and 18912 deletions
@@ -19,9 +19,8 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useState, useContext } from 'react';
import { Link } from 'react-router-dom';
import { Button } from '@douyinfe/semi-ui';
import { IconCreditCard } from '@douyinfe/semi-icons';
import { Share2, BookOpen, MonitorDown } from 'lucide-react';
import { Button as AntButton, Divider, Tooltip } from 'antd';
import { Share2, BookOpen, Download, Wallet } from 'lucide-react';
import NewYearButton from './NewYearButton';
import NotificationButton from './NotificationButton';
import ThemeToggle from './ThemeToggle';
@@ -141,72 +140,58 @@ const ActionButtons = ({
isActionVisible('theme') ||
languageSwitchEnabled;
// 进入用户区前是否需要分隔线(任一侧有按钮即显示)
const hasHeaderActions = hasPrimaryActions || hasUtilityActions;
const actionIcon = (Icon) => <Icon size={16} strokeWidth={1.5} aria-hidden />;
return (
<div className='flex items-center shrink-0 gap-0.5 sm:gap-2 md:gap-3'>
<div className='ui-header-actions flex items-center shrink-0'>
{/* Tutorial Button - 新手教程按钮 (桌面端显示) */}
{isLoggedIn && isButtonVisible('tutorial') && (
<Link to='/tutorial' className='hidden sm:block'>
<Button
theme='light'
type='primary'
icon={<BookOpen size={15} />}
className='group/btn hover:!bg-brand/10 dark:hover:!bg-brand/20 !text-brand-deep dark:!text-brand-from !border !border-brand/30 dark:!border-brand/25 hover:!border-brand/50 !rounded-full !px-3.5 !h-8 !transition-all !duration-200 !shadow-sm hover:!shadow-md hover:!shadow-brand/20 hover:!-translate-y-0.5 active:!translate-y-0'
style={{ background: 'var(--semi-color-primary-light-default)' }}
>
{!isMobile && <span className='font-medium'>{t('新手教程')}</span>}
</Button>
<AntButton icon={actionIcon(BookOpen)}>
{!isMobile && t('新手教程')}
</AntButton>
</Link>
)}
{/* Promotion Button - 推广按钮 (桌面端显示) */}
{isLoggedIn && isButtonVisible('pricing') && (
<Button
theme='light'
type='primary'
icon={<Share2 size={15} />}
className='hidden sm:!inline-flex hover:!bg-brand/10 dark:hover:!bg-brand/20 !text-brand-deep dark:!text-brand-from !border !border-brand/30 dark:!border-brand/25 hover:!border-brand/50 !rounded-full !px-3.5 !h-8 !transition-all !duration-200 !shadow-sm hover:!shadow-md hover:!shadow-brand/20 hover:!-translate-y-0.5 active:!translate-y-0'
style={{ background: 'var(--semi-color-primary-light-default)' }}
<AntButton
icon={actionIcon(Share2)}
className='hidden sm:!inline-flex'
onClick={() => setPromotionVisible(true)}
>
{!isMobile && <span className='font-medium'>{t('推广')}</span>}
</Button>
{!isMobile && t('推广')}
</AntButton>
)}
{/* WeyAi 桌面端下载 - 有 WeyAi 访问权限且下载页已开放时显示 (桌面端显示) */}
{showWeyAiDownload && (
<Link
to='/weyai/download'
className='hidden sm:block'
aria-label={t('下载 WeyAi 桌面端')}
>
<Button
theme='light'
type='primary'
icon={<MonitorDown size={15} />}
className='group/btn hover:!bg-brand/10 dark:hover:!bg-brand/20 !text-brand-deep dark:!text-brand-from !border !border-brand/30 dark:!border-brand/25 hover:!border-brand/50 !rounded-full !px-3.5 !h-8 !transition-all !duration-200 !shadow-sm hover:!shadow-md hover:!shadow-brand/20 hover:!-translate-y-0.5 active:!translate-y-0'
style={{ background: 'var(--semi-color-primary-light-default)' }}
<Tooltip title={t('下载 WeyAi')}>
<Link
to='/weyai/download'
className='hidden sm:block'
aria-label={t('下载 WeyAi 桌面端')}
>
{!isMobile && (
<span className='font-medium'>{t('下载 WeyAi')}</span>
)}
</Button>
</Link>
<AntButton
type='text'
className='ui-header-download'
icon={actionIcon(Download)}
>
{!isMobile && t('下载 WeyAi')}
</AntButton>
</Link>
</Tooltip>
)}
{/* Recharge Button - 充值按钮 (primary CTA) */}
{/* Recharge Button - 充值按钮 */}
{isButtonVisible('recharge') && (
<Link to='/recharge'>
<Button
theme='solid'
type='primary'
icon={<IconCreditCard />}
className='!bg-gradient-to-r !from-brand !to-brand-deep dark:!from-brand dark:!to-brand-deep !text-white !border-none !rounded-full !px-3 sm:!px-4 !h-7 sm:!h-8 !font-semibold !transition-all !duration-200 !shadow-md !shadow-brand/30 hover:!shadow-lg hover:!shadow-brand/45 hover:!-translate-y-0.5 active:!translate-y-0 active:!scale-[0.98]'
<AntButton
icon={actionIcon(Wallet)}
aria-label={isMobile ? t('充值') : undefined}
>
{!isMobile && <span className='font-medium'>{t('充值')}</span>}
</Button>
{!isMobile && t('充值')}
</AntButton>
</Link>
)}
@@ -215,15 +200,20 @@ const ActionButtons = ({
onClose={() => setPromotionVisible(false)}
/>
{/* Divider */}
{/* Divider:原型仅在主操作与工具按钮之间保留一条竖线 */}
{hasPrimaryActions && hasUtilityActions && (
<div className='hidden md:block w-px h-6 bg-gradient-to-b from-transparent via-gray-300 dark:via-neutral-600 to-transparent mx-1' />
<Divider type='vertical' className='ui-header-actions-divider' />
)}
{isActionVisible('newYear') && (
<NewYearButton isNewYear={isNewYear} t={t} />
)}
{isActionVisible('theme') && (
<ThemeToggle theme={theme} onThemeToggle={onThemeToggle} t={t} />
)}
{/* 系统公告:原型位于主题与语言之间 */}
{isActionVisible('notifications') && (
<NotificationButton
unreadCount={unreadCount}
@@ -232,10 +222,6 @@ const ActionButtons = ({
/>
)}
{isActionVisible('theme') && (
<ThemeToggle theme={theme} onThemeToggle={onThemeToggle} t={t} />
)}
{languageSwitchEnabled && (
<LanguageSelector
currentLang={currentLang}
@@ -244,11 +230,6 @@ const ActionButtons = ({
/>
)}
{/* Divider before user area(认证页 UserArea 通常为空,不渲染悬空分隔线) */}
{hasHeaderActions && !isAuthPage && (
<div className='hidden md:block w-px h-6 bg-gradient-to-b from-transparent via-gray-300 dark:via-neutral-600 to-transparent mx-1' />
)}
<UserArea
userState={userState}
isLoading={isLoading}
@@ -257,6 +238,7 @@ const ActionButtons = ({
headerNavModules={headerNavModules}
rightActions={headerNavModules?.rightActions}
sidebarModulesAdmin={sidebarModulesAdmin}
isOrgUser={isOrgUser}
logout={logout}
navigate={navigate}
t={t}
+22 -29
View File
@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import React from 'react';
import { Link } from 'react-router-dom';
import { Typography, Tag } from '@douyinfe/semi-ui';
import { Tag } from '@/components/ui';
import SkeletonWrapper from '../components/SkeletonWrapper';
const HeaderLogo = ({
@@ -38,41 +38,34 @@ const HeaderLogo = ({
}
return (
<Link to='/' className='group flex items-center gap-2'>
<div className='relative w-8 h-8 md:w-8 md:h-8'>
<Link to='/' className='ui-header-logo group flex items-center'>
<div className='ui-header-logo-mark relative'>
<SkeletonWrapper loading={isLoading || !logoLoaded} type='image' />
<img
src={logo}
alt='logo'
className={`absolute inset-0 w-full h-full transition-all duration-200 group-hover:scale-110 rounded-full ${!isLoading && logoLoaded ? 'opacity-100' : 'opacity-0'}`}
className={`absolute inset-0 w-full h-full object-contain ${!isLoading && logoLoaded ? 'opacity-100' : 'opacity-0'}`}
/>
</div>
<div className='hidden md:flex items-center gap-2'>
<div className='flex items-center gap-2'>
<SkeletonWrapper
loading={isLoading}
type='title'
width={120}
height={24}
<div className='hidden md:flex items-center gap-2 min-w-0'>
<SkeletonWrapper
loading={isLoading}
type='title'
width={120}
height={24}
>
<span className='ui-header-brand-name'>{systemName}</span>
</SkeletonWrapper>
{(isSelfUseMode || isDemoSiteMode) && !isLoading && (
<Tag
color={isSelfUseMode ? 'purple' : 'blue'}
className='text-xs px-1.5 py-0.5 rounded whitespace-nowrap shadow-sm'
size='small'
shape='circle'
>
<Typography.Title
heading={4}
className='!text-lg !font-semibold !mb-0'
>
{systemName}
</Typography.Title>
</SkeletonWrapper>
{(isSelfUseMode || isDemoSiteMode) && !isLoading && (
<Tag
color={isSelfUseMode ? 'purple' : 'blue'}
className='text-xs px-1.5 py-0.5 rounded whitespace-nowrap shadow-sm'
size='small'
shape='circle'
>
{isSelfUseMode ? t('自用模式') : t('演示站点')}
</Tag>
)}
</div>
{isSelfUseMode ? t('自用模式') : t('演示站点')}
</Tag>
)}
</div>
</Link>
);
@@ -18,10 +18,10 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useEffect, useState } from 'react';
import { Button, Dropdown } from '@douyinfe/semi-ui';
import { Button as AntButton } from 'antd';
import { Dropdown } from '@/components/ui';
import { Globe } from 'lucide-react';
import { CN, GB, JP, KR, TH, VN } from 'country-flag-icons/react/3x2';
import { useActualTheme } from '../../../context/Theme';
import { normalizeLanguage } from '../../../i18n/language';
import { orderEnabledLanguages } from '../../../i18n/catalog';
import {
@@ -36,10 +36,6 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
// i18n.language 可能带地区码(如 zh-CN / en-US),高亮判断先归一化;
// 繁体靠地区码区分,不能简单取主语言
const lang = normalizeLanguage(currentLang);
// 与 ThemeToggle 同规范:图标颜色随实际主题动态取色(Semi 暗色由
// body[theme-mode] 驱动,Tailwind dark: 类在此不可靠),菜单样式走
// semi-color token 天然亮暗自适应
const actualTheme = useActualTheme();
// 首访时后台判定可能晚于顶栏首次渲染:结果写入缓存后重新读取启用语言,
// 避免列出后台已停用的语言
@@ -54,8 +50,8 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
const getItemClassName = (isSelected) =>
`!flex !items-center !gap-2 !px-3 !py-1.5 !text-sm ${
isSelected
? '!bg-semi-color-primary-light-default !font-semibold'
: 'hover:!bg-semi-color-fill-1'
? '!bg-ui-color-primary-light-default !font-semibold'
: 'hover:!bg-ui-color-fill-1'
}`;
// 展示哪些语言、按什么顺序由后台「语言与地区」配置决定(经 /api/i18n/locale 缓存下发)
@@ -82,21 +78,12 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
</Dropdown.Menu>
}
>
<span className='inline-flex'>
<Button
icon={<Globe size={20} />}
aria-label={t('common.changeLanguage')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
</span>
<AntButton
type='text'
icon={<Globe size={16} strokeWidth={1.5} aria-hidden />}
aria-label={t('common.changeLanguage')}
className='ui-header-icon-action'
/>
</Dropdown>
);
};
@@ -18,8 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from '@douyinfe/semi-ui';
import { IconClose, IconMenu } from '@douyinfe/semi-icons';
import { Button } from '@/components/ui';
import { IconClose, IconMenu } from '@/components/ui/icons';
const MobileMenuButton = ({
isConsoleRoute,
@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { Button, Dropdown } from '@douyinfe/semi-ui';
import { Button, Dropdown } from '@/components/ui';
import { Compass, ExternalLink } from 'lucide-react';
/**
@@ -141,7 +141,7 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
aria-haspopup='menu'
aria-expanded={visible}
icon={<Compass 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 [&_.semi-button-content]:min-w-0'
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 ? activeItem.text : t('导航')}
+6 -18
View File
@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import React from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Dropdown } from '@douyinfe/semi-ui';
import { Dropdown } from '@/components/ui';
import { useTranslation } from 'react-i18next';
import SkeletonWrapper from '../components/SkeletonWrapper';
@@ -29,11 +29,10 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
const renderNavLinks = () => {
const baseClasses =
'nav-item-enhanced flex-shrink-0 flex items-center gap-1.5 font-semibold rounded-xl transition-all duration-300 ease-out relative overflow-hidden group';
'ui-header-nav-item flex-shrink-0 flex items-center gap-1.5 font-medium relative';
const defaultClasses = 'text-gray-600 dark:text-neutral-300';
const hoverClasses = 'hover:text-brand-deep dark:hover:text-brand-from';
const activeClasses =
'text-brand-deep dark:text-brand-from bg-brand/5 dark:bg-brand-deep/30';
const activeClasses = 'text-brand-deep dark:text-brand-from';
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
@@ -65,11 +64,6 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
isActive = isPathActive(link.activePrefix || targetPath);
}
// Hover background effect component
const hoverBg = (
<span className='absolute inset-0 bg-gradient-to-r from-brand-from/10 via-brand-via/5 to-brand-to/10 dark:from-brand-from/40 dark:via-brand-via/30 dark:to-brand-to/40 opacity-0 group-hover:opacity-100 transition-opacity duration-300 rounded-xl' />
);
const finalClasses = `${baseClasses} ${spacingClasses} ${isActive ? `nav-item-active ${activeClasses}` : `${defaultClasses} ${hoverClasses}`}`;
if (link.items && link.items.length > 0) {
@@ -79,12 +73,9 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
trigger={'hover'}
position={'bottomLeft'}
render={
<Dropdown.Menu className='!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'>
<Dropdown.Menu>
{link.items.map((subItem) => (
<Dropdown.Item
key={subItem.itemKey}
className='!rounded-lg !mx-1 !my-0.5 hover:!bg-brand/5 dark:hover:!bg-brand-deep/30 transition-colors'
>
<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'
@@ -98,7 +89,6 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
}
>
<div className={`${finalClasses} cursor-pointer`}>
{hoverBg}
{linkContent}
{/* Dropdown arrow */}
<svg
@@ -128,7 +118,6 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
rel='noopener noreferrer'
className={`${baseClasses} ${spacingClasses} ${defaultClasses} ${hoverClasses}`}
>
{hoverBg}
{linkContent}
{/* External link icon */}
<svg
@@ -155,7 +144,6 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
className={finalClasses}
aria-current={isActive ? 'page' : undefined}
>
{hoverBg}
{linkContent}
</Link>
);
@@ -165,7 +153,7 @@ const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
return (
<nav
aria-label={t('主导航')}
className='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'
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}
@@ -18,7 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button, Dropdown } from '@douyinfe/semi-ui';
import { Button as AntButton } from 'antd';
import { Dropdown } from '@/components/ui';
import fireworks from 'react-fireworks';
const NewYearButton = ({ isNewYear, t }) => {
@@ -38,22 +39,21 @@ const NewYearButton = ({ isNewYear, t }) => {
<Dropdown
position='bottomRight'
render={
<Dropdown.Menu className='!bg-semi-color-bg-overlay !border-semi-color-border !shadow-lg !rounded-lg dark:!bg-gray-700 dark:!border-gray-600'>
<Dropdown.Menu className='!bg-ui-color-bg-overlay !border-ui-color-border !shadow-lg !rounded-lg dark:!bg-gray-700 dark:!border-gray-600'>
<Dropdown.Item
onClick={handleNewYearClick}
className='!text-semi-color-text-0 hover:!bg-semi-color-fill-1 dark:!text-gray-200 dark:hover:!bg-gray-600'
className='!text-ui-color-text-0 hover:!bg-ui-color-fill-1 dark:!text-gray-200 dark:hover:!bg-gray-600'
>
{t('新年快乐')} 🎉
</Dropdown.Item>
</Dropdown.Menu>
}
>
<Button
theme='borderless'
type='tertiary'
<AntButton
type='text'
icon={<span className='text-xl'>🎉</span>}
aria-label={t('新年快乐')}
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center !text-current hover:!bg-brand/10 dark:hover:!bg-brand/15 !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
className='ui-header-icon-action'
/>
</Dropdown>
);
@@ -18,64 +18,23 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button, Badge } from '@douyinfe/semi-ui';
import { useActualTheme } from '../../../context/Theme';
import { Badge, Button, Tooltip } from 'antd';
import { Volume1 } from 'lucide-react';
// 自定义通知图标 — 圆角方形气泡 + 圆点指示
const NoticeIcon = ({ size = 19, color = 'currentColor' }) => (
<svg
width={size}
height={size}
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<rect
x='3'
y='4'
width='18'
height='14'
rx='4'
stroke={color}
strokeWidth='1.7'
/>
<circle cx='8.5' cy='11' r='1.25' fill={color} />
<circle cx='12' cy='11' r='1.25' fill={color} />
<circle cx='15.5' cy='11' r='1.25' fill={color} />
<path
d='M8 18l2.5-3h3L16 18'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
// 系统公告入口:34px text 按钮、16px 喇叭图标。
// 显隐(rightActions.notifications)、点击(打开 NoticeModal)与未读数均沿用原逻辑。
const NotificationButton = ({ unreadCount, onNoticeOpen, t }) => (
<Tooltip title={t('系统公告')}>
<Badge count={unreadCount} overflowCount={99} size='small'>
<Button
type='text'
className='ui-header-icon-action'
aria-label={t('系统公告')}
icon={<Volume1 size={16} strokeWidth={1.5} aria-hidden />}
onClick={onNoticeOpen}
/>
</Badge>
</Tooltip>
);
const NotificationButton = ({ unreadCount, onNoticeOpen, t }) => {
const actualTheme = useActualTheme();
const isDark = actualTheme === 'dark';
const buttonProps = {
icon: <NoticeIcon size={19} />,
'aria-label': t('系统公告'),
onClick: onNoticeOpen,
theme: 'borderless',
type: 'tertiary',
className:
'!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95',
style: { color: isDark ? 'rgba(243,244,246,0.9)' : 'rgba(75,85,99,1)' },
};
if (unreadCount > 0) {
return (
<Badge count={unreadCount} type='danger' overflowCount={99}>
<Button {...buttonProps} />
</Badge>
);
}
return <Button {...buttonProps} />;
};
export default NotificationButton;
+16 -247
View File
@@ -17,257 +17,26 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useMemo } from 'react';
import { Button, Dropdown } from '@douyinfe/semi-ui';
import React from 'react';
import { Button, Tooltip } from 'antd';
import { Moon, Sun } from 'lucide-react';
import { useActualTheme } from '../../../context/Theme';
// 自定义浅色图标 — 带光芒的太阳
const LightIcon = ({ size = 18, color = 'currentColor' }) => (
<svg
width={size}
height={size}
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<circle cx='12' cy='12' r='4.5' stroke={color} strokeWidth='1.7' />
<line
x1='12'
y1='2.5'
x2='12'
y2='5'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='12'
y1='19'
x2='12'
y2='21.5'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='21.5'
y1='12'
x2='19'
y2='12'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='5'
y1='12'
x2='2.5'
y2='12'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='18.7'
y1='5.3'
x2='16.9'
y2='7.1'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='7.1'
y1='16.9'
x2='5.3'
y2='18.7'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='18.7'
y1='18.7'
x2='16.9'
y2='16.9'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='7.1'
y1='7.1'
x2='5.3'
y2='5.3'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
</svg>
);
// 自定义深色图标 — 带星星的弯月
const DarkIcon = ({ size = 18, color = 'currentColor' }) => (
<svg
width={size}
height={size}
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<path
d='M20.5 13.5a8.5 8.5 0 01-10-10A8.5 8.5 0 1020.5 13.5z'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
strokeLinejoin='round'
/>
<circle cx='18' cy='5' r='0.8' fill={color} />
<circle cx='20.5' cy='8' r='0.6' fill={color} />
<circle cx='16' cy='3' r='0.5' fill={color} />
</svg>
);
// 自定义自动模式图标 — 半日半月
const AutoIcon = ({ size = 18, color = 'currentColor' }) => (
<svg
width={size}
height={size}
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<circle cx='12' cy='12' r='8.5' stroke={color} strokeWidth='1.7' />
<path d='M12 3.5v17a8.5 8.5 0 000-17z' fill={color} fillOpacity='0.2' />
<line
x1='12'
y1='1.5'
x2='12'
y2='3.5'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='12'
y1='20.5'
x2='12'
y2='22.5'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='22.5'
y1='12'
x2='20.5'
y2='12'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
<line
x1='3.5'
y1='12'
x2='1.5'
y2='12'
stroke={color}
strokeWidth='1.7'
strokeLinecap='round'
/>
</svg>
);
const ThemeToggle = ({ theme, onThemeToggle, t }) => {
const actualTheme = useActualTheme();
const themeOptions = useMemo(
() => [
{
key: 'light',
icon: <LightIcon />,
buttonIcon: <LightIcon />,
label: t('浅色模式'),
description: t('始终使用浅色主题'),
},
{
key: 'dark',
icon: <DarkIcon />,
buttonIcon: <DarkIcon />,
label: t('深色模式'),
description: t('始终使用深色主题'),
},
{
key: 'auto',
icon: <AutoIcon />,
buttonIcon: <AutoIcon />,
label: t('自动模式'),
description: t('跟随系统主题设置'),
},
],
[t],
);
const getItemClassName = (isSelected) =>
isSelected
? '!bg-semi-color-primary-light-default !font-semibold'
: 'hover:!bg-semi-color-fill-1';
const currentButtonIcon = useMemo(() => {
const currentOption = themeOptions.find((option) => option.key === theme);
return currentOption?.buttonIcon || themeOptions[2].buttonIcon;
}, [theme, themeOptions]);
const ThemeToggle = ({ onThemeToggle, t }) => {
const isDark = useActualTheme() === 'dark';
const label = isDark ? t('切换至亮色主题') : t('切换至暗色主题');
const Icon = isDark ? Sun : Moon;
return (
<Dropdown
position='bottomRight'
render={
<Dropdown.Menu>
{themeOptions.map((option) => (
<Dropdown.Item
key={option.key}
icon={option.icon}
onClick={() => onThemeToggle(option.key)}
className={getItemClassName(theme === option.key)}
>
<div className='flex flex-col'>
<span>{option.label}</span>
<span className='text-xs text-semi-color-text-2'>
{option.description}
</span>
</div>
</Dropdown.Item>
))}
{theme === 'auto' && (
<>
<Dropdown.Divider />
<div className='px-3 py-2 text-xs text-semi-color-text-2'>
{t('当前跟随系统')}:
{actualTheme === 'dark' ? t('深色') : t('浅色')}
</div>
</>
)}
</Dropdown.Menu>
}
>
{/* Semi can resolve a DOM trigger directly without findDOMNode. */}
<span className='inline-flex'>
<Button
icon={currentButtonIcon}
aria-label={t('切换主题')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
</span>
</Dropdown>
<Tooltip title={label}>
<Button
type='text'
icon={<Icon size={16} strokeWidth={1.5} aria-hidden />}
aria-label={t('切换主题')}
className='ui-header-icon-action'
onClick={() => onThemeToggle(isDark ? 'light' : 'dark')}
/>
</Tooltip>
);
};
+124 -271
View File
@@ -17,19 +17,30 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import React, { useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Avatar, Button, Dropdown, Typography } from '@douyinfe/semi-ui';
import { ChevronDown, User, Key, LogOut } from 'lucide-react';
import {
getUserAvatarUrl,
stringToColor,
isAuthPagePath,
} from '../../../helpers';
import { Avatar, Button as AntButton, Dropdown as AntDropdown } from 'antd';
import { Button } from '@/components/ui';
import { ChevronDown, UserRound, KeyRound, LogOut } from 'lucide-react';
import { getUserAvatarUrl, isAuthPagePath } from '../../../helpers';
import SkeletonWrapper from '../components/SkeletonWrapper';
import { useActualTheme } from '../../../context/Theme';
import { isHeaderModuleEnabled } from '../../../constants/headerNavModules';
// 头像菜单项:图标框 + 标题 + 说明(原型 account-menu-label)
const AccountMenuLabel = ({ icon, tone, title, description }) => (
<div className='ui-account-menu-label'>
<span className={`ui-account-menu-icon ui-account-menu-icon-${tone}`}>
{icon}
</span>
<span>
{title}
<small>{description}</small>
</span>
</div>
);
const MENU_ICON_PROPS = { size: 18, strokeWidth: 1.65, 'aria-hidden': true };
const UserArea = ({
userState,
isLoading,
@@ -38,13 +49,13 @@ const UserArea = ({
headerNavModules,
rightActions = {},
sidebarModulesAdmin = {},
isOrgUser = false,
logout,
navigate,
t,
}) => {
const location = useLocation();
const actualTheme = useActualTheme();
const isDark = actualTheme === 'dark';
const [open, setOpen] = useState(false);
const isActionVisible = (key) => rightActions?.[key] !== false;
const hasHeaderModuleConfig =
headerNavModules && Object.keys(headerNavModules).length > 0;
@@ -73,271 +84,113 @@ const UserArea = ({
if (userState.user) {
const displayName = userState.user.display_name || userState.user.username;
const avatarUrl = getUserAvatarUrl(userState.user);
const avatarInitial = displayName[0].toUpperCase();
const showSettings =
isActionVisible('userSettings') &&
isTopNavModuleVisible('userCenter') &&
isSidebarModuleVisible('userCenter', 'settings');
// 「秘钥管理快捷入口」由 rightActions.keyManagement 单独控制(运营设置→顶栏管理)。
// 个人用户的 /user-center/key-management 路由不依赖顶栏模块是否显示,故顶栏导航隐藏该模块时
// 头像菜单仍保留入口;企业员工只有在其顶栏模块放开时路由才被放行,继续联动判断。
const showKeyManagement =
isActionVisible('keyManagement') &&
(!isOrgUser || isTopNavModuleVisible('keyManagement'));
const items = [];
if (showSettings) {
items.push({
key: 'settings',
label: (
<AccountMenuLabel
tone='user'
icon={<UserRound {...MENU_ICON_PROPS} />}
title={t('个人设置')}
description={t('管理账户信息')}
/>
),
onClick: () => navigate('/user-center/settings'),
});
}
if (showKeyManagement) {
items.push({
key: 'keys',
label: (
<AccountMenuLabel
tone='key'
icon={<KeyRound {...MENU_ICON_PROPS} />}
title={t('密钥管理')}
description={t('查看和管理 API 密钥')}
/>
),
onClick: () => navigate('/user-center/key-management'),
});
}
items.push({ key: 'account-divider', type: 'divider' });
items.push({
key: 'logout',
label: (
<AccountMenuLabel
tone='logout'
icon={<LogOut {...MENU_ICON_PROPS} />}
title={t('退出登录')}
description={t('安全退出账户')}
/>
),
onClick: logout,
});
return (
<Dropdown
trigger='hover'
position='bottomRight'
showTick
render={
<Dropdown.Menu
className='!min-w-[180px] !p-2 !backdrop-blur-xl !border !shadow-xl !rounded-xl'
style={{
backgroundColor: isDark
? 'rgba(31,41,55,0.95)'
: 'rgba(255,255,255,0.95)',
borderColor: isDark ? 'rgba(55,65,81,1)' : 'rgba(243,244,246,1)',
boxShadow: isDark
? '0 20px 25px -5px rgba(0,0,0,0.3)'
: '0 20px 25px -5px rgba(0,0,0,0.05)',
}}
>
{/* 用户信息头部 */}
<div
className='px-3 py-2 mb-2 border-b'
style={{
borderColor: isDark
? 'rgba(55,65,81,1)'
: 'rgba(243,244,246,1)',
}}
>
<div className='flex items-center gap-3'>
<Avatar
size='small'
src={avatarUrl}
color={stringToColor(displayName)}
className='!w-8 !h-8 !text-xs'
>
{displayName[0].toUpperCase()}
</Avatar>
<div>
<div
className='text-sm font-semibold'
style={{
color: isDark
? 'rgba(243,244,246,0.9)'
: 'rgba(31,41,55,1)',
}}
>
{displayName}
</div>
<div
className='text-xs'
style={{
color: isDark
? 'rgba(107,114,128,1)'
: 'rgba(156,163,175,1)',
}}
>
{userState.user.email || t('已登录')}
</div>
</div>
</div>
</div>
{isActionVisible('userSettings') &&
isTopNavModuleVisible('userCenter') &&
isSidebarModuleVisible('userCenter', 'settings') && (
<Dropdown.Item
onClick={() => {
navigate('/user-center/settings');
}}
className='!px-3 !py-2.5 !rounded-lg !text-sm !transition-all !duration-200'
style={{
color: isDark ? 'rgba(229,231,235,1)' : 'rgba(55,65,81,1)',
}}
>
<div className='flex items-center gap-3'>
<div
className='w-8 h-8 rounded-lg flex items-center justify-center'
style={{
background: isDark
? 'rgba(30,58,138,0.5)'
: 'linear-gradient(to bottom right, rgba(219,234,254,1), rgba(224,231,255,1))',
}}
>
<User
size={16}
style={{
color: isDark
? 'rgba(96,165,250,1)'
: 'rgba(37,99,235,1)',
}}
/>
</div>
<div>
<div
className='font-medium'
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : undefined,
}}
>
{t('个人设置')}
</div>
<div
className='text-xs'
style={{
color: isDark
? 'rgba(107,114,128,1)'
: 'rgba(156,163,175,1)',
}}
>
{t('管理账户信息')}
</div>
</div>
</div>
</Dropdown.Item>
)}
{isActionVisible('keyManagement') &&
isTopNavModuleVisible('keyManagement') && (
<Dropdown.Item
onClick={() => {
navigate('/key-management');
}}
className='!px-3 !py-2.5 !rounded-lg !text-sm !transition-all !duration-200'
style={{
color: isDark ? 'rgba(229,231,235,1)' : 'rgba(55,65,81,1)',
}}
>
<div className='flex items-center gap-3'>
<div
className='w-8 h-8 rounded-lg flex items-center justify-center'
style={{
background: isDark
? 'rgba(120,53,15,0.5)'
: 'linear-gradient(to bottom right, rgba(254,243,199,1), rgba(255,237,213,1))',
}}
>
<Key
size={16}
style={{
color: isDark
? 'rgba(251,191,36,1)'
: 'rgba(217,119,6,1)',
}}
/>
</div>
<div>
<div
className='font-medium'
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : undefined,
}}
>
{t('秘钥管理')}
</div>
<div
className='text-xs'
style={{
color: isDark
? 'rgba(107,114,128,1)'
: 'rgba(156,163,175,1)',
}}
>
{t('查看和管理API秘钥')}
</div>
</div>
</div>
</Dropdown.Item>
)}
<div
className='my-2 border-t'
style={{
borderColor: isDark
? 'rgba(55,65,81,1)'
: 'rgba(243,244,246,1)',
}}
/>
<Dropdown.Item
onClick={logout}
className='!px-3 !py-2.5 !rounded-lg !text-sm !transition-all !duration-200'
style={{
color: isDark ? 'rgba(229,231,235,1)' : 'rgba(55,65,81,1)',
}}
>
<div className='flex items-center gap-3'>
<div
className='w-8 h-8 rounded-lg flex items-center justify-center'
style={{
background: isDark
? 'rgba(127,29,29,0.5)'
: 'linear-gradient(to bottom right, rgba(254,226,226,1), rgba(255,228,230,1))',
}}
>
<LogOut
size={16}
style={{
color: isDark
? 'rgba(248,113,113,1)'
: 'rgba(220,38,38,1)',
}}
/>
</div>
<div>
<div
className='font-medium'
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : undefined,
}}
>
{t('退出登录')}
</div>
<div
className='text-xs'
style={{
color: isDark
? 'rgba(107,114,128,1)'
: 'rgba(156,163,175,1)',
}}
>
{t('安全退出账户')}
</div>
</div>
</div>
</Dropdown.Item>
</Dropdown.Menu>
}
>
<span className='inline-flex'>
<Button
theme='borderless'
type='tertiary'
className='flex items-center gap-2 !pl-1.5 !pr-2.5 !py-1.5 !h-10 !rounded-full hover:!bg-brand/10 dark:hover:!bg-brand/15 !bg-transparent !transition-all !duration-200 hover:!-translate-y-0.5 group'
>
<div className='relative'>
<AntDropdown
trigger={['hover']}
placement='bottomRight'
open={open}
onOpenChange={setOpen}
overlayClassName='ui-account-dropdown'
menu={{ items, onClick: () => setOpen(false) }}
popupRender={(menu) => (
<div className='ui-account-panel'>
<div className='ui-account-summary'>
<Avatar
size='small'
shape='square'
size={40}
src={avatarUrl}
color={stringToColor(displayName)}
className='!w-7 !h-7 !text-xs ring-2 ring-white dark:ring-gray-800 group-hover:!ring-brand/40 dark:group-hover:!ring-brand/50 transition-all'
className='ui-account-avatar'
>
{displayName[0].toUpperCase()}
{avatarInitial}
</Avatar>
{/* 在线状态点 */}
<span className='absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-emerald-500 border-2 border-white dark:border-gray-800 rounded-full' />
<div>
<strong>{displayName}</strong>
<span>{userState.user.email || t('已登录')}</span>
</div>
</div>
<span className='hidden md:flex flex-col items-start'>
<Typography.Text
className='!text-sm !font-medium !leading-none'
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : 'rgba(55,65,81,1)',
}}
>
{displayName}
</Typography.Text>
</span>
<ChevronDown
size={14}
style={{
color: isDark ? 'rgba(209,213,219,1)' : 'rgba(156,163,175,1)',
}}
className='group-hover:!opacity-80 transition-colors'
/>
</Button>
</span>
</Dropdown>
{menu}
</div>
)}
>
<AntButton
type='text'
className='ui-header-account'
aria-haspopup='menu'
aria-expanded={open}
>
<Avatar
shape='square'
size={38}
src={avatarUrl}
className='ui-account-avatar'
>
{avatarInitial}
</Avatar>
<span className='ui-header-account-name'>{displayName}</span>
<ChevronDown
size={10}
strokeWidth={1.5}
aria-hidden
className={`ui-header-account-chevron${open ? ' is-open' : ''}`}
/>
</AntButton>
</AntDropdown>
);
} else {
if (isAuthPage) {
@@ -356,7 +209,7 @@ const UserArea = ({
let registerButtonClasses = `${commonSizingAndLayoutClass}`;
const loginButtonTextSpanClass =
'!text-xs !text-semi-color-text-1 dark:!text-gray-300 !p-1.5';
'!text-xs !text-ui-color-text-1 dark:!text-gray-300 !p-1.5';
const registerButtonTextSpanClass = '!text-xs !text-white !p-1.5';
if (showRegisterButton) {
+8 -5
View File
@@ -74,7 +74,7 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
const userRole = userState?.user?.role || 0;
const userGroup = userState?.user?.group || 'default';
const { mainNavLinks } = useNavigation(
const { mainNavLinks: configuredNavLinks } = useNavigation(
t,
docsLink,
headerNavModules,
@@ -82,9 +82,12 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
userGroup,
{ showOrgEntry, orgEntryPath },
);
const mainNavLinks = configuredNavLinks.filter(
(link) => link.itemKey !== 'keyManagement',
);
return (
<header className='text-semi-color-text-0 sticky top-0 z-50 transition-all duration-300 relative'>
<header className='text-ui-color-text-0 sticky top-0 z-50 transition-all duration-300 relative'>
{/* ===== BACKGROUND LAYERS ===== */}
{/* Main gradient background with glassmorphism */}
@@ -116,12 +119,12 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
unreadKeys={getUnreadKeys()}
/>
<div className='relative w-full px-2 sm:px-3 md:px-4'>
<div className='ui-topbar relative w-full'>
{/* 高度断点必须用 md(768) 而非 sm(640):PageLayout 的 headerBarHeight 按
MOBILE_BREAKPOINT=768 算 56/64,用 sm 会让 640~767px 区间实际 64px、
而侧栏 top、抽屉遮罩 top 全按 56px 定位,差 8px。 */}
<div className='flex items-center justify-between gap-1 md:gap-0 h-14 md:h-16'>
<div className='flex items-center min-w-0 md:min-w-[auto]'>
<div className='flex items-center justify-between gap-1 md:gap-0 h-14 md:h-[72px]'>
<div className='ui-header-brand flex items-center min-w-0 md:min-w-[auto]'>
<MobileMenuButton
isConsoleRoute={isConsoleRoute}
isMobile={isMobile}