From 48bab50a7e4ab5000385d7f0ad9d8be30f1cd460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Tue, 27 May 2025 16:26:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(components):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20YlTable=20=E7=BB=84=E4=BB=B6=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构了 tableWidth 计算逻辑,提高了代码可读性和性能 - 添加了 doc_content 类名,便于样式管理和维护 - 使用可选链操作符简化了代码结构 --- src/components/YlTable/yl-table-h.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/YlTable/yl-table-h.vue b/src/components/YlTable/yl-table-h.vue index 585b1d1..6356b5f 100644 --- a/src/components/YlTable/yl-table-h.vue +++ b/src/components/YlTable/yl-table-h.vue @@ -34,15 +34,15 @@ function handleTouchMove(event: TouchEvent) { watch( () => data.value, (newVal) => { + let width = document.getElementsByClassName('doc_content')[0]?.clientWidth + ? document.getElementsByClassName('doc_content')[0]?.clientWidth + : document.body.clientWidth; tableWidth.value = prop.value.length * 100; if (prop.value.length <= 3) { // tableWidth.value 判断是否铺满横屏 没有就铺满 - tableWidth.value = document.documentElement.clientWidth - 60; + tableWidth.value = width; } else { - tableWidth.value = - document.documentElement.clientWidth - 60 - prop.value.length * 100 > 0 - ? document.documentElement.clientWidth - : prop.value.length * 100; + tableWidth.value = width - prop.value.length * 100 > 0 ? width : prop.value.length * 100; } }, { @@ -58,6 +58,7 @@ watch( ref="doc_content" @touchstart="handleTouchStart" @touchmove="handleTouchMove" + class="doc_content" >
@@ -78,7 +78,7 @@ @blur="handleMaxSizeBlur" @update:model-value=" (value) => { - actionQuestion.config.max_size = value === '' ? 0 : value; + actionQuestion.config.max_size = value === '' ? 1 : value; } " >