From 0710e7cccf08381b08e3fa15a439ec041ad73e5a Mon Sep 17 00:00:00 2001 From: HongxuanG <1359774872@qq.com> Date: Sat, 31 Oct 2026 20:41:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=80=89=E6=8B=A9=E5=99=A8=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E6=A1=86=E9=94=99=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/u-select/u-select.vue | 55 ++++++++++++++++++++++++++-- src/pages/sys/login/index.vue | 9 ++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/components/u-select/u-select.vue b/src/components/u-select/u-select.vue index 6a86c20..a05b2bd 100644 --- a/src/components/u-select/u-select.vue +++ b/src/components/u-select/u-select.vue @@ -46,20 +46,27 @@ > 搜索中... - + 无匹配选项 - - {{ item1[labelName] }} + + {{ item1[labelName] }} @@ -172,6 +179,16 @@ export default { debounce: { type: Number, default: 400 + }, + /** 选项行高(rpx)。App 端需与 indicator 同步,避免选中框错位 */ + itemHeight: { + type: [Number, String], + default: 0 + }, + /** 可见行数,用于计算滚轮高度;需为奇数,选中行才能居中 */ + visibleItemCount: { + type: [Number, String], + default: 5 } }, data() { @@ -225,7 +242,37 @@ export default { }, isColumnEmpty() { return !this.columnData || !this.columnData.length || !this.columnData[0] || !this.columnData[0].length; - } + }, + hasCustomItemHeight() { + return Number(this.itemHeight) > 0; + }, + itemHeightRpx() { + return Number(this.itemHeight) || 70; + }, + itemHeightPx() { + return uni.upx2px(this.itemHeightRpx); + }, + visibleCount() { + const n = Number(this.visibleItemCount) || 5; + return n % 2 === 0 ? n + 1 : n; + }, + indicatorStyle() { + if (!this.hasCustomItemHeight) return ''; + return `height: ${this.itemHeightPx}px;`; + }, + itemStyle() { + return { + height: `${this.itemHeightPx}px`, + lineHeight: `${this.itemHeightPx}px`, + }; + }, + pickerViewStyle() { + if (!this.hasCustomItemHeight) return null; + return { height: `${this.itemHeightPx * this.visibleCount}px` }; + }, + bodyStyle() { + return this.pickerViewStyle; + }, }, methods: { pickstart() { diff --git a/src/pages/sys/login/index.vue b/src/pages/sys/login/index.vue index 8725a39..9663b8b 100644 --- a/src/pages/sys/login/index.vue +++ b/src/pages/sys/login/index.vue @@ -105,7 +105,8 @@ + title="选择服务器" :show-search="false" :item-height="88" :visible-item-count="5" + @confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"> 版本: {{ appVersion }} @@ -607,15 +608,13 @@ export default { font-size: 36rpx; } - ::v-deep .u-select__body { - height: 560rpx; + ::v-deep .u-select__header__title { + font-size: 36rpx; } ::v-deep .u-select__body__picker-view__item, ::v-deep .u-line-1 { - height: 88rpx; font-size: 40rpx; - line-height: 88rpx; } }