perf(build): 优化开发预热与首屏分包懒加载
减少应用启动时的静态依赖,增加首屏体积预算与懒加载边界校验。验证通过:875 项单测、UI 依赖审计、ESLint、Prettier、生产构建与首屏产物校验;Chrome 模拟回归通过。
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
|
||||
const AgreementModal = lazy(
|
||||
() => import('../common/DocumentRenderer/AgreementModal'),
|
||||
);
|
||||
|
||||
export default function LazyAgreementModal(props) {
|
||||
if (!props.type) return null;
|
||||
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<AgreementModal {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ import GlassCard from './GlassCard';
|
||||
import AuthCardHeader from './AuthCardHeader';
|
||||
import AuthLoginTabs from './AuthLoginTabs';
|
||||
import AuthDivider from './AuthDivider';
|
||||
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||
import AgreementModal from './LazyAgreementModal';
|
||||
import {
|
||||
isMiniProgramWebView,
|
||||
withMiniProgramLogins,
|
||||
|
||||
@@ -48,7 +48,7 @@ import AuthCardHeader from './AuthCardHeader';
|
||||
import AuthLoginTabs from './AuthLoginTabs';
|
||||
import AuthDivider from './AuthDivider';
|
||||
import { Shield, Smartphone, QrCode } from 'lucide-react';
|
||||
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||
import AgreementModal from './LazyAgreementModal';
|
||||
import {
|
||||
isMiniProgramWebView,
|
||||
withMiniProgramLogins,
|
||||
|
||||
@@ -11,17 +11,15 @@ import React, {
|
||||
} from 'react';
|
||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers/api';
|
||||
import { isAuthPagePath } from '../../helpers/auth';
|
||||
import {
|
||||
API,
|
||||
clearUserData,
|
||||
getUserData,
|
||||
getLogo,
|
||||
getSystemName,
|
||||
isAuthPagePath,
|
||||
showError,
|
||||
setStatusData,
|
||||
setUserData,
|
||||
} from '../../helpers';
|
||||
} from '../../helpers/data';
|
||||
import { getLogo, getSystemName, showError } from '../../helpers/utils';
|
||||
import { UserContext } from '../../context/User';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
@@ -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 按
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import * as Ant from 'antd';
|
||||
export { Checkbox, Col, Grid, List, Slider } from 'antd';
|
||||
import { controlSize, placement } from './controls';
|
||||
import {
|
||||
centerPaginationEvents,
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
export * from './controls';
|
||||
export { Form, withField } from './form';
|
||||
export { Chat } from './chat';
|
||||
export const { Checkbox, Col, Grid, List, Slider } = Ant;
|
||||
export const Layout = Object.assign(
|
||||
forwardRef(function Layout({ style, hasSider, ...props }, ref) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user