|
@@ -113,19 +113,19 @@ const handleIframeLoad = async (event: Event) => {
|
|
const iframeHead = iframeDoc.head || iframeDoc.getElementsByTagName('head')[0]
|
|
const iframeHead = iframeDoc.head || iframeDoc.getElementsByTagName('head')[0]
|
|
|
|
|
|
if (iframeHead) {
|
|
if (iframeHead) {
|
|
- // 使用fetch获取JS文件内容
|
|
|
|
|
|
+ // 使用动态导入获取JS文件内容
|
|
const jsFiles = [
|
|
const jsFiles = [
|
|
- { id: 'aws-sdk', url: '/src/views/components/element/FrameElement/aws-sdk-2.235.1.min.js' },
|
|
|
|
- { id: 'jquery', url: '/src/views/components/element/FrameElement/jquery-3.6.0.min.js' },
|
|
|
|
- { id: 'jietu', url: '/src/views/components/element/FrameElement/jietu.js' }
|
|
|
|
|
|
+ { id: 'aws-sdk', importPath: () => import('./aws-sdk-2.235.1.min.js?raw') },
|
|
|
|
+ { id: 'jquery', importPath: () => import('./jquery-3.6.0.min.js?raw') },
|
|
|
|
+ { id: 'jietu', importPath: () => import('./jietu.js?raw') }
|
|
]
|
|
]
|
|
|
|
|
|
for (const jsFile of jsFiles) {
|
|
for (const jsFile of jsFiles) {
|
|
try {
|
|
try {
|
|
// 检查是否已经注入过
|
|
// 检查是否已经注入过
|
|
if (!iframeDoc.getElementById(jsFile.id)) {
|
|
if (!iframeDoc.getElementById(jsFile.id)) {
|
|
- const response = await fetch(jsFile.url)
|
|
|
|
- const jsContent = await response.text()
|
|
|
|
|
|
+ const jsModule = await jsFile.importPath()
|
|
|
|
+ const jsContent = jsModule.default || jsModule
|
|
|
|
|
|
const scriptElement = iframeDoc.createElement('script')
|
|
const scriptElement = iframeDoc.createElement('script')
|
|
scriptElement.id = jsFile.id
|
|
scriptElement.id = jsFile.id
|