Refactor(Code): Optimize code

This commit is contained in:
2024-10-31 16:03:57 +08:00
parent 51dc1ed377
commit 9d1d5b10d6
2 changed files with 10 additions and 9 deletions

View File

@@ -58,15 +58,16 @@ const Render = ({ iframeKey, compiledCode, mobileMode = false }: RenderProps) =>
}
useEffect(() => {
if (isLoaded) {
iframeRef.current?.contentWindow?.postMessage(
{
type: 'UPDATE',
data: { compiledCode }
} as IMessage,
'*'
)
if (!isLoaded) {
return
}
iframeRef.current?.contentWindow?.postMessage(
{
type: 'UPDATE',
data: { compiledCode }
} as IMessage,
'*'
)
}, [isLoaded, compiledCode])
return mobileMode ? (

View File

@@ -38,7 +38,7 @@ const Simulation = ({ data }: NodeProps<SimulationNode>) => {
ref={data.iframeRef}
src={data.iframeUrl}
onLoad={() => data.setIsLoaded(true)}
sandbox="allow-downloads allow-forms allow-modals allow-scripts"
sandbox={'allow-downloads allow-forms allow-modals allow-scripts'}
allow={'clipboard-read; clipboard-write'}
/>
</div>