diff --git a/src/views/Admin.vue b/src/views/Admin.vue index 077deb5..c0094de 100644 --- a/src/views/Admin.vue +++ b/src/views/Admin.vue @@ -1533,7 +1533,7 @@ * 7. 新闻管理 - CRUD + 置顶/分组 * 8. 轮播管理 - 添加/删除/排序/启用 */ -import { ref, reactive, onMounted, watch, computed, nextTick } from 'vue' +import { ref, reactive, onMounted, watch, computed, nextTick, defineAsyncComponent, h } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { DataAnalysis, User, EditPen, FolderOpened, @@ -1546,7 +1546,21 @@ import * as carouselApi from '@/api/carousel' import { formatFileSize, normalizeImageUrl } from '@/utils/upload' import { safeDownload, fetchBlobGuarded } from '@/utils/download' import { sanitizeHtml, isRichTextEmpty } from '@/utils/richtext' -import RichEditor from '@/components/RichEditor.vue' +// 🔴 富文本编辑器**异步加载**(2026-09-29 R41 · BACKLOG C6): +// RichEditor.vue 静态 import 了 @wangeditor/editor(dist 主文件 818,777 B ≈ 800 kB), +// 此前经静态 import 全量并进 Admin chunk ⇒ Admin-*.js 达 1021 kB(gzip 340 kB)。 +// 实测三处使用点(446 大题题干 / 1384 新闻 / 1476 轮播)**全部在 el-dialog 内**, +// 而 el-dialog 初始 rendered=false 不渲染内容 ⇒ 进入管理端时本编辑器根本用不到。 +// 改为异步后 wangeditor 被剥离为独立 chunk,仅在首次打开这三个弹窗时才按需下载。 +// 注意:loadingComponent 用 render 函数而非 template 字符串 —— 本工程为 runtime-only +// 构建,字符串模板需要运行时编译器,会直接报错。 +const RichEditor = defineAsyncComponent({ + loader: () => import('@/components/RichEditor.vue'), + loadingComponent: { + render: () => h('div', { style: 'padding:24px;color:#909399;font-size:13px;text-align:center' }, '富文本编辑器加载中…'), + }, + delay: 120, +}) const authStore = useAuthStore()