perf(build): 优化开发预热与首屏分包懒加载
减少应用启动时的静态依赖,增加首屏体积预算与懒加载边界校验。验证通过:875 项单测、UI 依赖审计、ESLint、Prettier、生产构建与首屏产物校验;Chrome 模拟回归通过。
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import React from 'react';
|
||||
import React, { lazy, Suspense, useEffect, useState } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { isAuthPagePath } from '../../../helpers';
|
||||
import { isAuthPagePath } from '../../../helpers/auth';
|
||||
import { useHeaderBar } from '../../../hooks/common/useHeaderBar';
|
||||
import { useNotifications } from '../../../hooks/common/useNotifications';
|
||||
import { useNavigation } from '../../../hooks/common/useNavigation';
|
||||
import { usePartnerWorkspaceEntry } from '../../../hooks/common/usePartnerWorkspaceEntry';
|
||||
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 NoticeModal = lazy(() => import('../NoticeModal'));
|
||||
|
||||
const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
||||
const location = useLocation();
|
||||
// 认证页(登录/注册/企业登录等)顶栏按行业惯例最小化:
|
||||
@@ -69,6 +70,11 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
||||
(link) => link.itemKey !== 'keyManagement',
|
||||
);
|
||||
|
||||
const [hasOpenedNotice, setHasOpenedNotice] = useState(false);
|
||||
useEffect(() => {
|
||||
if (noticeVisible) setHasOpenedNotice(true);
|
||||
}, [noticeVisible]);
|
||||
|
||||
return (
|
||||
<header className='text-ui-color-text-0 sticky top-0 z-50 transition-all duration-300 relative'>
|
||||
{/* ===== BACKGROUND LAYERS ===== */}
|
||||
@@ -94,13 +100,17 @@ const HeaderBar = ({ onMobileMenuToggle, drawerOpen }) => {
|
||||
/>
|
||||
|
||||
{/* ===== CONTENT ===== */}
|
||||
<NoticeModal
|
||||
visible={noticeVisible}
|
||||
onClose={handleNoticeClose}
|
||||
isMobile={isMobile}
|
||||
defaultTab={unreadCount > 0 ? 'system' : 'inApp'}
|
||||
unreadKeys={getUnreadKeys()}
|
||||
/>
|
||||
{(noticeVisible || hasOpenedNotice) && (
|
||||
<Suspense fallback={null}>
|
||||
<NoticeModal
|
||||
visible={noticeVisible}
|
||||
onClose={handleNoticeClose}
|
||||
isMobile={isMobile}
|
||||
defaultTab={unreadCount > 0 ? 'system' : 'inApp'}
|
||||
unreadKeys={getUnreadKeys()}
|
||||
/>
|
||||
</Suspense>
|
||||
)}
|
||||
|
||||
<div className='ui-topbar relative w-full'>
|
||||
{/* 高度断点必须用 md(768) 而非 sm(640):PageLayout 的 headerBarHeight 按
|
||||
|
||||
Reference in New Issue
Block a user