perf: 优化依赖与首屏加载

This commit is contained in:
zhanjunhao
2026-10-28 11:37:15 +08:00
parent f9dd9297b8
commit b8659d0a9a
11 changed files with 541 additions and 504 deletions
+28 -18
View File
@@ -17,9 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import HeaderBar from './headerbar';
import { Layout } from '@douyinfe/semi-ui';
import SiderBar from './SiderBar';
import App from '../../App';
import { ToastContainer } from 'react-toastify';
import React, {
@@ -49,7 +47,11 @@ import { useLocation } from 'react-router-dom';
import { applyTheme, setPresetOverrides } from '../../helpers/theme';
// 用户问卷功能已禁用
// import UserSurveyModal from '../common/modals/UserSurveyModal';
import NewUserGiftModal from '../common/modals/NewUserGiftModal';
const HeaderBar = lazy(() => import('./headerbar'));
const SiderBar = lazy(() => import('./SiderBar'));
const NewUserGiftModal = lazy(
() => import('../common/modals/NewUserGiftModal'),
);
// 懒加载客服浮窗组件 - 非核心功能,延迟加载
const CustomerServiceFloat = lazy(() => import('../customer-service'));
@@ -355,10 +357,12 @@ const PageLayout = () => {
zIndex: 100,
}}
>
<HeaderBar
onMobileMenuToggle={() => setDrawerOpen((prev) => !prev)}
drawerOpen={drawerOpen}
/>
<Suspense fallback={null}>
<HeaderBar
onMobileMenuToggle={() => setDrawerOpen((prev) => !prev)}
drawerOpen={drawerOpen}
/>
</Suspense>
{/* 跑马灯公告 - 固定在导航栏正下方;认证页不展示(与 hasMarquee 的高度计算保持一致) */}
{!isAuthPage && <Marquee />}
</Header>
@@ -406,12 +410,14 @@ const PageLayout = () => {
: undefined,
}}
>
<SiderBar
forceExpanded={siderForceExpanded}
onNavigate={() => {
if (isMobile) setDrawerOpen(false);
}}
/>
<Suspense fallback={null}>
<SiderBar
forceExpanded={siderForceExpanded}
onNavigate={() => {
if (isMobile) setDrawerOpen(false);
}}
/>
</Suspense>
</Sider>
)}
<Layout
@@ -470,11 +476,15 @@ const PageLayout = () => {
/> */}
{/* 新用户注册赠送额度弹窗 */}
<NewUserGiftModal
visible={showGiftModal}
onClose={() => setShowGiftModal(false)}
quota={giftQuota}
/>
{showGiftModal && (
<Suspense fallback={null}>
<NewUserGiftModal
visible={showGiftModal}
onClose={() => setShowGiftModal(false)}
quota={giftQuota}
/>
</Suspense>
)}
</Layout>
);
};