|
|
@@ -132,7 +132,7 @@ import message from '@/utils/message'
|
|
|
|
|
|
const slidesStore = useSlidesStore()
|
|
|
const manager = useVideoManager()
|
|
|
-const { getFile, getFile2, getHtmlPureJS } = useImport()
|
|
|
+const { getFile, getFile2 } = useImport()
|
|
|
|
|
|
const props = defineProps({
|
|
|
elementInfo: {
|
|
|
@@ -356,30 +356,31 @@ const handleIframeLoad = async (event: Event) => {
|
|
|
slidesStore.updateElement({ id: info.id, props: { isDone: true } })
|
|
|
}
|
|
|
else {
|
|
|
- message.info('type=73 跨域,尝试抓取 HTML 做 srcdoc')
|
|
|
+ // message.info('type=73 跨域,尝试抓取 HTML 做 srcdoc')
|
|
|
console.log('type=73 跨域,尝试抓取 HTML 做 srcdoc')
|
|
|
let html: string | null = null
|
|
|
try {
|
|
|
html = await api.getHTML(info.url)
|
|
|
}
|
|
|
catch (_e) {
|
|
|
- message.info('getHTML 失败,尝试 getFile' + _e)
|
|
|
+ // message.info('getHTML 失败,尝试 getFile' + _e)
|
|
|
try {
|
|
|
const fd = await getFile(info.url)
|
|
|
if (fd?.data) html = new TextDecoder('utf-8').decode(new Uint8Array(fd.data))
|
|
|
}
|
|
|
catch (_e2) {
|
|
|
- message.info('getFile 失败,尝试 getFile2' + _e2)
|
|
|
+ // message.info('getFile 失败,尝试 getFile2' + _e2)
|
|
|
try {
|
|
|
const fd2 = await getFile2(info.url)
|
|
|
if (fd2?.data) html = new TextDecoder('utf-8').decode(new Uint8Array(fd2.data))
|
|
|
}
|
|
|
catch (e3) {
|
|
|
- message.info('getFile2 失败,尝试 getHtmlPureJS' + e3)
|
|
|
- // 最后兜底:纯 JS + CORS 代理抓取
|
|
|
+ // message.info('getFile2 失败,尝试后端 proxyHtml' + e3)
|
|
|
+ // 最后兜底:自家后端代理代抓(放最后防止服务器过载)
|
|
|
// 不用在这里注入 <base>:processedSrcDoc 会根据 curl 统一注入
|
|
|
try {
|
|
|
- html = await getHtmlPureJS(info.url)
|
|
|
+ const ph = await api.proxyHtml(info.url)
|
|
|
+ if (ph) html = ph
|
|
|
}
|
|
|
catch (error) {
|
|
|
message.warning('type=73 抓取全部失败:' + error)
|