From c9094b465b7c76476ebcb228ea58bde286c9ed7e Mon Sep 17 00:00:00 2001 From: vincentinttsh Date: Sun, 24 Jan 2021 17:46:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=9C=96=E6=AA=94=E7=9A=84?= =?UTF-8?q?=E3=80=8C=E5=88=AA=E9=99=A4=E3=80=8D=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/components/main.vue | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/components/main.vue b/js/components/main.vue index 8dd2edf..e92a6a4 100644 --- a/js/components/main.vue +++ b/js/components/main.vue @@ -7,7 +7,7 @@ var mainWindow = { 'selectDepartment': '', 'foundName': "", "user": "", - 'token': "", + 'token': "", 'is_print': false, } }, @@ -196,16 +196,23 @@ var mainWindow = { }, 'generatePic': function () { var main = this - main.is_print = true; - html2canvas(document.getElementById('course-table-div')).then(function (canvas) { - var a = document.createElement('a'); - a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); - a.download = '課表.jpg'; - a.click(); + const doPrint = new Promise((resolve, reject) => { + main.is_print = true; + resolve(); }); - setTimeout(function(){ + doPrint + .then(() =>{ + html2canvas(document.getElementById('course-table-div')).then(function (canvas) { + var a = document.createElement('a'); + a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream"); + a.download = '課表.jpg'; + a.click(); + }); + console.log("adasd"); + }) + .then(() => { main.is_print = false; - }, 5000); + }) }, 'share': function () { if (this.user != "")