From c4911f853e9c1c3ed6d1aeca934479e9043ec4d1 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 20 Mar 2023 18:41:19 +0800
Subject: [PATCH] 增加跨端通讯,全局通知容错能力

---
 plugins/qrcode/CQRCode.vue |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/plugins/qrcode/CQRCode.vue b/plugins/qrcode/CQRCode.vue
index ef9fe4a..8acaae5 100644
--- a/plugins/qrcode/CQRCode.vue
+++ b/plugins/qrcode/CQRCode.vue
@@ -33,7 +33,9 @@
         },
     },
     data() {
-        return {};
+        return {
+            lastContent: '',
+        };
     },
     methods: {
         _renderQRCode(canvasDom) {
@@ -58,9 +60,14 @@
             const canvasBox = $(this.$refs.canvas.$el);
             const finderTimer = setInterval(() => {
                 const canvasDom = canvasBox.find('canvas');
-                if (canvasDom.length > 0) {
-                    this._renderQRCode(canvasDom[0]);
+                if (canvasDom.length === 0) {
+                    return;
                 }
+                if (this.lastContent === this.content) {
+                    return;
+                }
+                this._renderQRCode(canvasDom[0]);
+                this.lastContent = this.content;
             }, 10);
         } else {
             // TODO: 小程序中获取canvas

--
Gitblit v1.9.1