diff --git a/console/src/components/MomentPreview.vue b/console/src/components/MomentPreview.vue index 72b4cb3..49e63cb 100644 --- a/console/src/components/MomentPreview.vue +++ b/console/src/components/MomentPreview.vue @@ -38,6 +38,28 @@ const vHighlight = { }, }; +const vLazy = { + mounted: (el: HTMLElement) => { + // iframe + const iframes = el.querySelectorAll("iframe"); + iframes.forEach((iframe: any) => { + iframe.loading = "lazy"; + iframe.importance = "low"; + }); + // 图片 + const imgs = el.querySelectorAll("img,image"); + imgs.forEach((img: HTMLImageElement) => { + img.loading = "lazy"; + }); + // 视频,音频 + const medium = el.querySelectorAll("video,audio"); + medium.forEach((media: HTMLMediaElement) => { + media.autoplay = false; + media.preload = "metadata"; + }); + }, +}; + const mediums = ref(props.moment.spec.content.medium || []); const detailVisible = ref(false); const selectedIndex = ref(0); @@ -151,7 +173,7 @@ const getExtname = (type: string) => {
-
+