|
@@ -64,7 +64,7 @@
|
|
|
<!-- 延迟加载iframe:只有在可见且不是缩略图时才加载 -->
|
|
<!-- 延迟加载iframe:只有在可见且不是缩略图时才加载 -->
|
|
|
<iframe
|
|
<iframe
|
|
|
:key="`html-${iframeKey}`"
|
|
:key="`html-${iframeKey}`"
|
|
|
- :srcdoc="elementInfo.url"
|
|
|
|
|
|
|
+ :srcdoc="processedSrcDoc"
|
|
|
v-else-if="elementInfo.isHTML && !isThumbnail && isVisible"
|
|
v-else-if="elementInfo.isHTML && !isThumbnail && isVisible"
|
|
|
:width="width"
|
|
:width="width"
|
|
|
:height="height"
|
|
:height="height"
|
|
@@ -161,6 +161,27 @@ const width = computed(() => {
|
|
|
return props.elementInfo.width * props.scale
|
|
return props.elementInfo.width * props.scale
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+// srcdoc 外链 CDN 镜像替换
|
|
|
|
|
+const CDN_RULES: [RegExp, string][] = [
|
|
|
|
|
+ [/cdn\.jsdelivr\.net/g, 'cdn.jsdmirror.com'],
|
|
|
|
|
+ [/fastly\.jsdelivr\.net/g, 'cdn.jsdmirror.com'],
|
|
|
|
|
+ [/gcore\.jsdelivr\.net/g, 'cdn.jsdmirror.com'],
|
|
|
|
|
+ [/unpkg\.com/g, 's4.zstatic.net/npm'],
|
|
|
|
|
+ [/cdnjs\.cloudflare\.com/g, 'cdnjs.loli.net'],
|
|
|
|
|
+ [/fonts\.googleapis\.com/g, 'fonts.loli.net'],
|
|
|
|
|
+ [/fonts\.gstatic\.com/g, 'gstatic.loli.net'],
|
|
|
|
|
+ [/code\.jquery\.com/g, 'cdn.jsdmirror.com/npm/jquery'],
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+const processedSrcDoc = computed(() => {
|
|
|
|
|
+ let html = props.elementInfo.url || ''
|
|
|
|
|
+ if (!html || typeof html !== 'string') return html
|
|
|
|
|
+ for (const [pattern, replacement] of CDN_RULES) {
|
|
|
|
|
+ html = html.replace(pattern, replacement)
|
|
|
|
|
+ }
|
|
|
|
|
+ return html
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const height = computed(() => {
|
|
const height = computed(() => {
|
|
|
return props.elementInfo.height * props.scale
|
|
return props.elementInfo.height * props.scale
|
|
|
})
|
|
})
|