Initial import of weiyuan frontend

This commit is contained in:
qiubaishen
2026-10-15 16:33:46 +08:00
commit d8f3aee261
774 changed files with 374914 additions and 0 deletions
@@ -0,0 +1,184 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
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 { Link, useLocation } from 'react-router-dom';
import { Dropdown } from '@douyinfe/semi-ui';
import { useTranslation } from 'react-i18next';
import SkeletonWrapper from '../components/SkeletonWrapper';
const Navigation = ({ mainNavLinks, isMobile, isLoading, userState }) => {
const location = useLocation();
const { t } = useTranslation();
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';
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 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}/`)
);
};
return mainNavLinks.map((link) => {
const linkContent = <span className='relative z-10'>{link.text}</span>;
// Calculate target path for main link(未登录默认引导到企业登录)
let targetPath = link.to;
if (link.requireAuth && !userState.user) {
targetPath = '/org/login';
}
if (link.itemKey === 'console' && !userState.user) {
targetPath = '/org/login';
}
// Check if active
let isActive = false;
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);
}
// 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) {
return (
<Dropdown
key={link.itemKey}
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'>
{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'
>
<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>
}
>
<div className={`${finalClasses} cursor-pointer`}>
{hoverBg}
{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>
</Dropdown>
);
}
if (link.isExternal && targetPath !== '/org/login') {
return (
<a
key={link.itemKey}
href={link.externalLink}
target='_blank'
rel='noopener noreferrer'
className={`${baseClasses} ${spacingClasses} ${defaultClasses} ${hoverClasses}`}
>
{hoverBg}
{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>
</a>
);
}
return (
<Link
key={link.itemKey}
to={targetPath}
className={finalClasses}
aria-current={isActive ? 'page' : undefined}
>
{hoverBg}
{linkContent}
</Link>
);
});
};
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'
>
<SkeletonWrapper
loading={isLoading}
type='navigation'
count={4}
width={60}
height={16}
isMobile={isMobile}
>
{renderNavLinks()}
</SkeletonWrapper>
</nav>
);
};
export default Navigation;