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() {