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
+202
View File
@@ -0,0 +1,202 @@
/*
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 { useLocation } from 'react-router-dom';
import { isAuthPagePath } from '../../../helpers';
import { useHeaderBar } from '../../../hooks/common/useHeaderBar';
import { useNotifications } from '../../../hooks/common/useNotifications';
import { useNavigation } from '../../../hooks/common/useNavigation';
import NoticeModal from '../NoticeModal';
import MobileMenuButton from './MobileMenuButton';
import HeaderLogo from './HeaderLogo';
import Navigation from './Navigation';
import MobileNavMenu from './MobileNavMenu';
import ActionButtons from './ActionButtons';
const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
const location = useLocation();
// 认证页(登录/注册/企业登录等)顶栏按行业惯例最小化:
// 隐藏主导航与需登录态的操作按钮,只保留 logo + 主题切换等基础工具
const isAuthPage = isAuthPagePath(location.pathname);
const {
userState,
statusState,
isMobile,
collapsed,
logoLoaded,
currentLang,
isLoading,
systemName,
logo,
isNewYear,
isSelfUseMode,
docsLink,
isDemoSiteMode,
isConsoleRoute,
theme,
headerNavModules,
sidebarModulesAdmin,
showOrgEntry,
orgEntryPath,
isOrgUser,
logout,
handleLanguageChange,
handleThemeToggle,
handleMobileMenuToggle,
navigate,
t,
} = useHeaderBar({ onMobileMenuToggle, drawerOpen });
const {
noticeVisible,
unreadCount,
handleNoticeOpen,
handleNoticeClose,
getUnreadKeys,
} = useNotifications(statusState);
const userRole = userState?.user?.role || 0;
const userGroup = userState?.user?.group || 'default';
const { mainNavLinks } = useNavigation(
t,
docsLink,
headerNavModules,
userRole,
userGroup,
{ showOrgEntry, orgEntryPath },
);
return (
<header className='text-semi-color-text-0 sticky top-0 z-50 transition-all duration-300 relative'>
{/* ===== BACKGROUND LAYERS ===== */}
{/* Main gradient background with glassmorphism */}
<div className='absolute inset-0 bg-gradient-to-r from-slate-50/95 via-white/90 to-slate-50/95 dark:from-slate-900/95 dark:via-neutral-900/90 dark:to-slate-900/95 backdrop-blur-xl' />
{/* Animated gradient accent - top edge */}
<div className='absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-brand-from via-brand-via to-brand-to opacity-80' />
{/* Subtle animated gradient orbs */}
<div className='absolute -top-20 -left-20 w-40 h-40 bg-gradient-to-br from-brand-from/20 to-brand-to/10 dark:from-brand-from/10 dark:to-brand-to/5 rounded-full blur-3xl pointer-events-none' />
<div className='absolute -top-20 -right-20 w-40 h-40 bg-gradient-to-bl from-brand-via/20 to-brand-to/10 dark:from-brand-via/10 dark:to-brand-to/5 rounded-full blur-3xl pointer-events-none' />
<div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-20 bg-gradient-to-r from-brand-from/5 via-brand-via/10 to-brand-to/5 dark:from-brand-from/5 dark:via-brand-via/5 dark:to-brand-to/5 rounded-full blur-2xl pointer-events-none' />
{/* Bottom border with gradient */}
<div className='absolute bottom-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent via-gray-200/80 to-transparent dark:via-neutral-700/50' />
{/* Subtle shimmer effect */}
<div
className='absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent dark:via-white/[0.02] animate-shimmer pointer-events-none'
style={{ backgroundSize: '200% 100%' }}
/>
{/* ===== CONTENT ===== */}
<NoticeModal
visible={noticeVisible}
onClose={handleNoticeClose}
isMobile={isMobile}
defaultTab={unreadCount > 0 ? 'system' : 'inApp'}
unreadKeys={getUnreadKeys()}
/>
<div className='relative w-full px-2 sm:px-3 md:px-4'>
{/* 高度断点必须用 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]'>
<MobileMenuButton
isConsoleRoute={isConsoleRoute}
isMobile={isMobile}
drawerOpen={drawerOpen}
collapsed={collapsed}
onToggle={handleMobileMenuToggle}
t={t}
/>
<HeaderLogo
isMobile={isMobile}
isConsoleRoute={isConsoleRoute}
logo={logo}
logoLoaded={logoLoaded}
isLoading={isLoading}
systemName={systemName}
isSelfUseMode={isSelfUseMode}
isDemoSiteMode={isDemoSiteMode}
t={t}
/>
{/* 移动端:主导航收进下拉菜单,避免与右侧操作区互相挤压 */}
{!isAuthPage && isMobile && !isLoading && (
<MobileNavMenu
mainNavLinks={mainNavLinks}
userState={userState}
t={t}
/>
)}
</div>
{!isAuthPage && !isMobile && (
<Navigation
mainNavLinks={mainNavLinks}
isMobile={isMobile}
isLoading={isLoading}
userState={userState}
/>
)}
<ActionButtons
isAuthPage={isAuthPage}
isNewYear={isNewYear}
unreadCount={unreadCount}
onNoticeOpen={handleNoticeOpen}
theme={theme}
onThemeToggle={handleThemeToggle}
currentLang={currentLang}
onLanguageChange={handleLanguageChange}
userState={userState}
isLoading={isLoading}
isMobile={isMobile}
isSelfUseMode={isSelfUseMode}
headerNavModules={headerNavModules}
sidebarModulesAdmin={sidebarModulesAdmin}
isOrgUser={isOrgUser}
logout={logout}
navigate={navigate}
t={t}
/>
</div>
</div>
{/* CSS for shimmer animation */}
<style>{`
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
.animate-shimmer {
animation: shimmer 8s ease-in-out infinite;
}
`}</style>
</header>
);
};
export default HeaderBar;