wui-components-v2 1.2.14 → 1.2.15

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.
@@ -44,6 +44,12 @@ const props = defineProps({
44
44
  type: Number,
45
45
  default: 4,
46
46
  },
47
+ // 自定义菜单项点击跳转:传了则在点击时调用,返回 true 表示已处理(不再走内置 gotoPage),
48
+ // 返回 false / 不返回则回退组件默认跳转逻辑。签名为 (item: MenuItem) => boolean | void
49
+ itemClick: {
50
+ type: Function as PropType<(item: any) => boolean | void>,
51
+ default: null,
52
+ },
47
53
  })
48
54
  const languageStore = useLanguageStore()
49
55
  const themeConfig = ref<any>({})
@@ -61,6 +67,12 @@ const {
61
67
  navTitle,
62
68
  } = useMenus(props, pagingRef)
63
69
 
70
+ // 统一菜单项点击:调用方传了 itemClick 且返回 true 表示已处理,否则走内置 gotoPage
71
+ function handleItemClick(item: any) {
72
+ if (props.itemClick && props.itemClick(item) === true) return
73
+ gotoPage(item)
74
+ }
75
+
64
76
  // 当 tile 为 true 时,将 filtermenu 中所有分类的 items 平铺到一个数组中
65
77
  const tileItems = computed(() => {
66
78
  if (!props.tile) return []
@@ -140,14 +152,14 @@ onMounted(() => {
140
152
  use-text-slot
141
153
  use-icon-slot
142
154
  class="menu-grid-item"
143
- @click="gotoPage(subItem)"
155
+ @click="handleItemClick(subItem)"
144
156
  >
145
157
  <template #icon>
146
158
  <slot
147
159
  name="menu-item-icon"
148
160
  :sub-item="subItem"
149
161
  :index="subIndex"
150
- :goto="gotoPage"
162
+ :goto="handleItemClick"
151
163
  :t="languageStore.t"
152
164
  >
153
165
  <view
@@ -164,7 +176,7 @@ onMounted(() => {
164
176
  name="menu-item-text"
165
177
  :sub-item="subItem"
166
178
  :index="subIndex"
167
- :goto="gotoPage"
179
+ :goto="handleItemClick"
168
180
  :t="languageStore.t"
169
181
  >
170
182
  <view class="menu-text-wrapper">
@@ -182,7 +194,12 @@ onMounted(() => {
182
194
  </template>
183
195
 
184
196
  <template v-else>
185
- <slot name="tile" :items="tileItems" :goto="gotoPage" :t="languageStore.t" />
197
+ <slot
198
+ name="tile"
199
+ :items="tileItems"
200
+ :goto="handleItemClick"
201
+ :t="languageStore.t"
202
+ />
186
203
  </template>
187
204
  </view>
188
205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",