Skip to content

Commit bd1d8e7

Browse files
committed
fix
1 parent b200ed2 commit bd1d8e7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

components/compiler/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export default function setCodeUid (code: string, path: string = '/mock.tsx') {
211211

212212
export function setHtmlCodeUid(code: string, path: string = '/mock.tsx') {
213213
var patternBody = /<body[^>]*>((.|[\n\r])*)<\/body>/im; //匹配header
214+
if (!code) return code;
214215
const headMatch = code.match(patternBody);
215216
if (headMatch) {
216217
const htmlCode = `

engine/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export default function PreviewBox({ code, appState, sendMessageChange, history
6363

6464
useEffect(() => {
6565
if (appState === AppState.CODE_READY) {
66-
const codeUid = setHtmlCodeUid(throttledCode);
66+
const codeUid = setHtmlCodeUid(code);
6767
designer.project.simulator?.writeIframeDocument(codeUid);
6868
} else {
6969
// designer.project.simulator?.writeIframeDocument(throttledCode);
7070
}
71-
}, [throttledCode]);
71+
}, [code, appState]);
7272

7373
const takeScreenshot = async (): Promise<string> => {
7474
const body = designer.project.simulator?.contentWindow?.document.body;

0 commit comments

Comments
 (0)