From e7157775af31b5050ba538a4127fb5e274351f23 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 19 Nov 2023 08:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Promise=E6=94=B9=E5=86=99?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/pages/Plan.vue | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/ui/src/pages/Plan.vue b/ui/src/pages/Plan.vue index 7f3a9f1bb..21cda8612 100644 --- a/ui/src/pages/Plan.vue +++ b/ui/src/pages/Plan.vue @@ -56,26 +56,22 @@ const loading_bar = useLoadingBar() async function save() { generating_image.value = true - facility.value = '' loading_bar.start() - sleep(500).then(() => { - html2canvas(plan_editor.value.outer, { - scale: 3, - backgroundColor: theme.value == 'light' ? '#ffffff' : '#000000' - }).then((canvas) => { - generating_image.value = false - loading_bar.finish() - const form_data = new FormData() - canvas.toBlob((blob) => { - form_data.append('img', blob) - axios - .post(`${import.meta.env.VITE_HTTP_URL}/dialog/save/img`, form_data) - .then(({ data }) => { - message.info(data) - }) - }) - }) + if (facility.value != '') { + facility.value = '' + await sleep(500) + } + const canvas = await html2canvas(plan_editor.value.outer, { + scale: 3, + backgroundColor: theme.value == 'light' ? '#ffffff' : '#000000' }) + generating_image.value = false + loading_bar.finish() + const form_data = new FormData() + const blob = await new Promise((resolve) => canvas.toBlob(resolve)) + form_data.append('img', blob) + const { data } = await axios.post(`${import.meta.env.VITE_HTTP_URL}/dialog/save/img`, form_data) + message.info(data) } const mobile = inject('mobile')