From dfe9d4a9453557b74ca3f034cc8133a0ea58b8d7 Mon Sep 17 00:00:00 2001 From: purocean Date: Wed, 12 Jan 2022 00:19:20 +0800 Subject: [PATCH] upd: update resize of drawio --- src/renderer/plugins/markdown-drawio.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/renderer/plugins/markdown-drawio.ts b/src/renderer/plugins/markdown-drawio.ts index b4907858..8aa6f1d7 100644 --- a/src/renderer/plugins/markdown-drawio.ts +++ b/src/renderer/plugins/markdown-drawio.ts @@ -54,10 +54,10 @@ const Drawio = defineComponent({ } } - const timer = setTimeout(resize, 1000) + let timer: any onBeforeUnmount(() => { - clearTimeout(timer) + timer && clearTimeout(timer) }) const button = (text: string, onClick: any) => h('button', { @@ -128,7 +128,10 @@ const Drawio = defineComponent({ h(IFrame, { html: srcdoc.value, ref: refIFrame, - onLoad: resize, + onLoad: () => { + resize() + timer = setTimeout(resize, 1000) + }, iframeProps: { class: 'drawio', height: '300px',