From e82de49379181fd58a1ae86c8138c62cd738d430 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 22 Jul 2025 11:25:39 +0800 Subject: [PATCH] refactor: canvas force update --- .../src/views/dashboard/canvas/CanvasCore.vue | 10 ++++++++++ .../views/dashboard/components/sq-text/index.vue | 15 +++++++-------- frontend/src/views/dashboard/editor/index.vue | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/src/views/dashboard/canvas/CanvasCore.vue b/frontend/src/views/dashboard/canvas/CanvasCore.vue index 2a6c141b..a1b8178d 100644 --- a/frontend/src/views/dashboard/canvas/CanvasCore.vue +++ b/frontend/src/views/dashboard/canvas/CanvasCore.vue @@ -1037,8 +1037,18 @@ function afterInitOk(func) { }, 100) } +const forceComputed = () => { + // Force the trigger of copy-add calculation here, as the position calculation uses a method and there is no change in internal style attributes + // In some cases, recalculation may not be triggered, resulting in a positional offset. The cellHeight property is being monitored, and forced recalculation is performed here + cellHeight.value = cellHeight.value + 0.001 + nextTick(function () { + cellHeight.value = cellHeight.value - 0.001 + }) +} + function addItemBox(item: CanvasItem) { canvasComponentData.value.push(item) + forceComputed() nextTick(() => { addItem(item, canvasComponentData.value.length - 1) }) diff --git a/frontend/src/views/dashboard/components/sq-text/index.vue b/frontend/src/views/dashboard/components/sq-text/index.vue index 5ad3fcb1..7b0ce874 100644 --- a/frontend/src/views/dashboard/components/sq-text/index.vue +++ b/frontend/src/views/dashboard/components/sq-text/index.vue @@ -1,8 +1,7 @@