wui-components-v2 1.2.14 → 1.2.16
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 []
|
|
@@ -88,10 +100,9 @@ onMounted(() => {
|
|
|
88
100
|
<slot name="top" :style="{ background: currentThemeColor.primary }" />
|
|
89
101
|
<view v-if="props.menuTopType === '自定义'" class="p-2" />
|
|
90
102
|
</template>
|
|
91
|
-
<template #topImg>
|
|
92
|
-
<slot name="topImg" />
|
|
93
|
-
</template>
|
|
94
103
|
<view class="px-3 pb-4">
|
|
104
|
+
<!-- 自定义顶部图片插槽:直接渲染在可滚动内容区顶部,避免被当作 z-paging 不存在的 topImg 插槽而丢弃 -->
|
|
105
|
+
<slot name="topImg" />
|
|
95
106
|
<!-- 菜单搜索 -->
|
|
96
107
|
<searchBar v-if="themeConfig?.showHomePage" />
|
|
97
108
|
<!-- 轮播图 -->
|
|
@@ -140,14 +151,14 @@ onMounted(() => {
|
|
|
140
151
|
use-text-slot
|
|
141
152
|
use-icon-slot
|
|
142
153
|
class="menu-grid-item"
|
|
143
|
-
@click="
|
|
154
|
+
@click="handleItemClick(subItem)"
|
|
144
155
|
>
|
|
145
156
|
<template #icon>
|
|
146
157
|
<slot
|
|
147
158
|
name="menu-item-icon"
|
|
148
159
|
:sub-item="subItem"
|
|
149
160
|
:index="subIndex"
|
|
150
|
-
:goto="
|
|
161
|
+
:goto="handleItemClick"
|
|
151
162
|
:t="languageStore.t"
|
|
152
163
|
>
|
|
153
164
|
<view
|
|
@@ -164,7 +175,7 @@ onMounted(() => {
|
|
|
164
175
|
name="menu-item-text"
|
|
165
176
|
:sub-item="subItem"
|
|
166
177
|
:index="subIndex"
|
|
167
|
-
:goto="
|
|
178
|
+
:goto="handleItemClick"
|
|
168
179
|
:t="languageStore.t"
|
|
169
180
|
>
|
|
170
181
|
<view class="menu-text-wrapper">
|
|
@@ -182,7 +193,12 @@ onMounted(() => {
|
|
|
182
193
|
</template>
|
|
183
194
|
|
|
184
195
|
<template v-else>
|
|
185
|
-
<slot
|
|
196
|
+
<slot
|
|
197
|
+
name="tile"
|
|
198
|
+
:items="tileItems"
|
|
199
|
+
:goto="handleItemClick"
|
|
200
|
+
:t="languageStore.t"
|
|
201
|
+
/>
|
|
186
202
|
</template>
|
|
187
203
|
</view>
|
|
188
204
|
|