refactor: 重构 RouterContainer 组件以支持懒加载页面模块
- 移除不必要的 Suspense 组件,改为使用 LoadedPage 组件进行懒加载。 - 更新特性获取逻辑,使用 getFeatureByKey 函数替代直接查找。 - 新增 featureMeta.ts 文件,集中管理功能配置和相关方法。 - 实现 pageLoaders 以支持按需加载页面模块,提升性能和用户体验。
This commit is contained in:
+5
-8
@@ -22,14 +22,10 @@ function manualChunksForHtmlOnly(): Plugin {
|
||||
) {
|
||||
return 'vendor-react';
|
||||
}
|
||||
// 二维码活态感知依赖分流
|
||||
if (id.includes('qr-scanner') || id.includes('qrious')) {
|
||||
return 'vendor-qr';
|
||||
}
|
||||
// 拖拽排序高级组件分流
|
||||
if (id.includes('@dnd-kit')) {
|
||||
return 'vendor-dnd';
|
||||
}
|
||||
|
||||
// qrious / qr-scanner / @dnd-kit 不单独拆 vendor chunk:
|
||||
// 独立 vendor 会与 Vite preload 辅助函数共 chunk,被 App Shell 静态拉取。
|
||||
// 这些依赖随各自页面 async chunk 加载即可。
|
||||
|
||||
return undefined;
|
||||
},
|
||||
@@ -77,6 +73,7 @@ export default defineConfig({
|
||||
vite: () => ({
|
||||
plugins: [manualChunksForHtmlOnly()],
|
||||
build: {
|
||||
modulePreload: false,
|
||||
minify: 'terser',
|
||||
terserOptions: {
|
||||
format: { ascii_only: true, comments: false },
|
||||
|
||||
Reference in New Issue
Block a user