Fix can not autoload in production mode bug
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
import '@/components/Playground/Output/Preview/preview.scss'
|
||||
import { IFiles, IImportMap } from '@/components/Playground/shared'
|
||||
import Compiler from '@/components/Playground/compiler'
|
||||
@@ -52,7 +51,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
|
||||
}
|
||||
}
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
useEffect(() => {
|
||||
window.addEventListener('message', handleMessage)
|
||||
|
||||
return () => {
|
||||
@@ -60,7 +59,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
useEffect(() => {
|
||||
Compiler.compile(files, importMap)
|
||||
.then((result) => {
|
||||
if (loaded) {
|
||||
@@ -70,7 +69,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
|
||||
} as IMessage)
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch((e: Error) => {
|
||||
setErrorMsg(`编译失败:${e.message}`)
|
||||
})
|
||||
}, [files, Compiler, loaded])
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[data-component=playground-preview] {
|
||||
display: flex;
|
||||
position: relative;
|
||||
|
||||
iframe {
|
||||
border: none;
|
||||
flex: 1;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import MonacoEditor from '@monaco-editor/react'
|
||||
import { Loader } from 'esbuild-wasm'
|
||||
import '@/components/Playground/Output/Transform/transform.scss'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
import { IFile, ITheme } from '@/components/Playground/shared'
|
||||
import { cssToJs, jsonToJs, addReactImport } from '@/components/Playground/files'
|
||||
import Compiler from '@/components/Playground/compiler'
|
||||
@@ -32,7 +31,7 @@ const Transform = ({ file, theme }: OutputProps) => {
|
||||
})
|
||||
}
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
useEffect(() => {
|
||||
if (file) {
|
||||
try {
|
||||
const code = file.value
|
||||
|
||||
Reference in New Issue
Block a user