From 608b089de19f16cb11dd04a4dec69d36910bad60 Mon Sep 17 00:00:00 2001 From: Jooolee Date: Wed, 14 May 2025 17:22:52 +0800 Subject: [PATCH] =?UTF-8?q?:=20=E6=96=B0=E5=A2=9E=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E6=87=92=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=87=8F=E5=B0=91=E5=88=9D?= =?UTF-8?q?=E6=AC=A1=E5=8A=A0=E8=BD=BD=E8=BF=87=E5=A4=9A=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E9=A1=B5=E9=9D=A2=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/editor/ComponentWrapper.vue | 50 ++++++++++++++++--- .../canvas/customComponent/UserView.vue | 18 +++++++ .../widget/deWidget/DeNumberRange.vue | 1 + 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/core/frontend/src/components/canvas/components/editor/ComponentWrapper.vue b/core/frontend/src/components/canvas/components/editor/ComponentWrapper.vue index 1e35b45813..b8ba20c9d2 100644 --- a/core/frontend/src/components/canvas/components/editor/ComponentWrapper.vue +++ b/core/frontend/src/components/canvas/components/editor/ComponentWrapper.vue @@ -2,6 +2,7 @@
-
+
@@ -52,9 +49,10 @@ /> { + const that = this + function handleIntersection(entries, observer) { + entries.forEach((entry) => { + if (entry.intersectionRatio > 0.1) { + that.renderCom = true + that.isActive = true + } else { + that.isActive = false + } + }) + } + const root = document.querySelector('#preview-main-canvas-main') + + // 创建一个IntersectionObserver实例 + const observer = new IntersectionObserver(handleIntersection, { + root: root, // 使用视口作为根 + rootMargin: '0px', + threshold: 0.1 // 元素进入视口的10%时触发回调 + }) + + // 选择需要观察的元素 + const targetElement = document.querySelector(`#wrapper_${this.config.id}`) + observer.observe(targetElement) + }) + }, computed: { filterActive() { return this.curComponent && this.config.id === this.curComponent.id && this.config.type === 'custom' diff --git a/core/frontend/src/components/canvas/customComponent/UserView.vue b/core/frontend/src/components/canvas/customComponent/UserView.vue index ac8df39751..89f6be9db4 100644 --- a/core/frontend/src/components/canvas/customComponent/UserView.vue +++ b/core/frontend/src/components/canvas/customComponent/UserView.vue @@ -364,6 +364,10 @@ export default { userId: { type: String, require: false + }, + isActive: { + type: Boolean, + default: true } }, data() { @@ -590,6 +594,15 @@ export default { }, watch: { + 'isActive': { + immediate: true, + handler(newVal) { + if (newVal && this.needUpdate) { + this.getData(this.element.propValue.viewId) + this.needUpdate = false + } + } + }, 'innerPadding': { handler: function(val1, val2) { if (val1 !== val2) { @@ -634,6 +647,11 @@ export default { if (this.requestStatus === 'waiting') { return } + if (!this.isActive) { + this.needUpdate = true + this.getDataLoading = false + return + } if (newVal !== oldVal && this.$refs[this.element.propValue.id]) { this.resizeChart() } diff --git a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue index bee6b686e1..aeeb02dc1d 100644 --- a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue +++ b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue @@ -161,6 +161,7 @@ export default { }, beforeDestroy() { bus.$off('reset-default-value', this.resetDefaultValue) + this.destroyTimeMachine() }, methods: { clearHandler() {