wui-components-v2 1.2.54 → 1.2.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, defineOptions } from 'vue'
3
+ import type { PropType } from 'vue'
3
4
  import { useMenus } from '../../../composables/useMenus'
4
5
  import { RainbowColorGenerator } from '../../../utils/index'
5
6
  import { useLanguageStore } from '../../../store/language'
@@ -7,6 +8,13 @@ import { useLanguageStore } from '../../../store/language'
7
8
  defineOptions({
8
9
  name: 'SectionMenus',
9
10
  })
11
+ // 自定义菜单项点击跳转:返回 true 表示已处理(不再走内置 gotoPage),返回 false / 不返回则回退默认跳转
12
+ const props = defineProps({
13
+ itemClick: {
14
+ type: Function as PropType<(item: any) => boolean | void>,
15
+ default: null,
16
+ },
17
+ })
10
18
  const {
11
19
  gotoPage,
12
20
  getSectionMenu,
@@ -25,6 +33,11 @@ const sectionmenuColor = computed(() => {
25
33
  }
26
34
  })
27
35
  })
36
+ // 统一菜单项点击:调用方传了 itemClick 且返回 true 表示已处理,否则走内置 gotoPage
37
+ function handleItemClick(item: any) {
38
+ if (props.itemClick && props.itemClick(item) === true) return
39
+ gotoPage(item)
40
+ }
28
41
  </script>
29
42
 
30
43
  <template>
@@ -46,13 +59,16 @@ const sectionmenuColor = computed(() => {
46
59
  </view> -->
47
60
  </view>
48
61
  <view class="recent-items">
49
- <view v-for="(i) in sectionmenuColor" :key="i.id" class="recent-item" @click="gotoPage(i)">
62
+ <view v-for="(i) in sectionmenuColor" :key="i.id" class="recent-item" @click="handleItemClick(i)">
50
63
  <view class="recent-icon" :style="{ background: i.color }">
51
64
  <text class="i-carbon:grid text-lg text-white dark:text-white" />
52
65
  </view>
53
- <text class="recent-label dark:text-white text-gray-500">
54
- {{ languageStore.t(i.title) }}
55
- </text>
66
+ <!-- 快速访问标题插槽:调用方可自定义标题内容(item 为菜单项对象,t 为翻译函数,goto 为跳转方法) -->
67
+ <slot name="section-item-text" :item="i" :t="languageStore.t" :goto="handleItemClick">
68
+ <text class="recent-label dark:text-white text-gray-500">
69
+ {{ languageStore.t(i.title) }}
70
+ </text>
71
+ </slot>
56
72
  </view>
57
73
  </view>
58
74
  </view>
@@ -128,7 +128,11 @@ onMounted(() => {
128
128
  <!-- 轮播图 -->
129
129
  <bannerCarousel v-if="themeConfig?.showHomePage && props.showBannerCarousel" />
130
130
  <!-- 快捷菜单 -->
131
- <sectionMenus v-if="themeConfig?.showHomePage && props.showSectionMenus" />
131
+ <sectionMenus v-if="themeConfig?.showHomePage && props.showSectionMenus" :item-click="handleItemClick">
132
+ <template #section-item-text="{ item, t, goto }">
133
+ <slot name="section-item-text" :item="item" :t="t" :goto="goto" />
134
+ </template>
135
+ </sectionMenus>
132
136
  <!-- 统计 -->
133
137
  <quickPanel v-if="themeConfig?.showHomePage && props.showQuickPanel" />
134
138
  <!-- 消息 -->
@@ -199,7 +203,7 @@ onMounted(() => {
199
203
  :t="languageStore.t"
200
204
  >
201
205
  <view class="menu-text-wrapper">
202
- <view class="menu-title text-ellipsis dark:text-white text-gray-800">
206
+ <view class="menu-title dark:text-white text-gray-800">
203
207
  {{ languageStore.t(subItem.title) }}
204
208
  </view>
205
209
  </view>
@@ -345,6 +349,10 @@ onMounted(() => {
345
349
  .menu-grid {
346
350
  // grid-auto-rows: 100px !important;
347
351
  :deep(.wd-grid-item) {
352
+ // 固定高度 + 禁止内容撑破,保证所有格子的图标垂直位置一致
353
+ height: 200rpx;
354
+ min-height: 0;
355
+ overflow: hidden;
348
356
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
349
357
 
350
358
  &:active {
@@ -352,8 +360,19 @@ onMounted(() => {
352
360
  }
353
361
  }
354
362
 
363
+ // 内容区撑满格子,让图标垂直居中一致
364
+ :deep(.wd-grid-item__content) {
365
+ height: 100%;
366
+ min-height: 0;
367
+ display: flex;
368
+ flex-direction: column;
369
+ overflow: hidden;
370
+ }
371
+
355
372
  :deep(.wd-grid-item__wrapper) {
356
- padding: 20rpx 10rpx !important;
373
+ flex: 1;
374
+ min-height: 0;
375
+ padding: 8rpx 10rpx !important;
357
376
  display: flex;
358
377
  flex-direction: column;
359
378
  align-items: center;
@@ -365,6 +384,7 @@ onMounted(() => {
365
384
  .menu-icon-wrapper {
366
385
  width: 100rpx;
367
386
  height: 100rpx;
387
+ flex-shrink: 0; // 关键:禁止在 flex 列布局中被压缩,保证高度一致
368
388
  border-radius: 28rpx;
369
389
  // box-shadow:
370
390
  // 0 8rpx 24rpx rgba(0, 0, 0, 0.12),
@@ -414,7 +434,7 @@ onMounted(() => {
414
434
 
415
435
  // 文本容器
416
436
  .menu-text-wrapper {
417
- padding-top: 16rpx;
437
+ padding-top: 8rpx;
418
438
  text-align: center;
419
439
  display: flex;
420
440
  flex-direction: column;
@@ -422,7 +442,7 @@ onMounted(() => {
422
442
  gap: 6rpx;
423
443
  }
424
444
 
425
- // 菜单标题
445
+ // 菜单标题:最多两行,超出隐藏;固定 2 行高度,保证图标垂直对齐
426
446
  .menu-title {
427
447
  font-size: 24rpx;
428
448
  font-weight: 600;
@@ -430,9 +450,14 @@ onMounted(() => {
430
450
  line-height: 1.3;
431
451
  letter-spacing: 0.02em;
432
452
  width: 100%;
433
- text-overflow: ellipsis;
434
- white-space: nowrap;
453
+ // 固定高度 = 2 行(24rpx * 1.3 * 2 ≈ 62rpx,留一点余量)
454
+ height: 64rpx;
455
+ display: -webkit-box;
456
+ -webkit-box-orient: vertical;
457
+ -webkit-line-clamp: 2;
458
+ line-clamp: 2;
435
459
  overflow: hidden;
460
+ word-break: break-all;
436
461
  }
437
462
 
438
463
  // 菜单徽章
@@ -636,4 +661,7 @@ onMounted(() => {
636
661
  .menu-grid-container :deep(.wd-grid-item__content) {
637
662
  align-items: normal;
638
663
  }
664
+ :deep(.wd-grid-item__content) {
665
+ background: transparent;
666
+ }
639
667
  </style>