wui-components-v2 1.2.13 → 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 []
|
|
@@ -88,6 +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>
|
|
103
|
+
<template #topImg>
|
|
104
|
+
<slot name="topImg" />
|
|
105
|
+
</template>
|
|
91
106
|
<view class="px-3 pb-4">
|
|
92
107
|
<!-- 菜单搜索 -->
|
|
93
108
|
<searchBar v-if="themeConfig?.showHomePage" />
|
|
@@ -112,7 +127,10 @@ onMounted(() => {
|
|
|
112
127
|
</text>
|
|
113
128
|
</view>
|
|
114
129
|
<view class="section-tag">
|
|
115
|
-
<text class="tag-text">
|
|
130
|
+
<text class="tag-text">
|
|
131
|
+
{{ props.tile ? tileItems.length : filtermenu.length }}
|
|
132
|
+
{{ props.tile ? languageStore.t('个功能') : languageStore.t('个分类') }}
|
|
133
|
+
</text>
|
|
116
134
|
</view>
|
|
117
135
|
</view>
|
|
118
136
|
<view v-else class="py-3"></view>
|
|
@@ -134,14 +152,14 @@ onMounted(() => {
|
|
|
134
152
|
use-text-slot
|
|
135
153
|
use-icon-slot
|
|
136
154
|
class="menu-grid-item"
|
|
137
|
-
@click="
|
|
155
|
+
@click="handleItemClick(subItem)"
|
|
138
156
|
>
|
|
139
157
|
<template #icon>
|
|
140
158
|
<slot
|
|
141
159
|
name="menu-item-icon"
|
|
142
160
|
:sub-item="subItem"
|
|
143
161
|
:index="subIndex"
|
|
144
|
-
:goto="
|
|
162
|
+
:goto="handleItemClick"
|
|
145
163
|
:t="languageStore.t"
|
|
146
164
|
>
|
|
147
165
|
<view
|
|
@@ -158,7 +176,7 @@ onMounted(() => {
|
|
|
158
176
|
name="menu-item-text"
|
|
159
177
|
:sub-item="subItem"
|
|
160
178
|
:index="subIndex"
|
|
161
|
-
:goto="
|
|
179
|
+
:goto="handleItemClick"
|
|
162
180
|
:t="languageStore.t"
|
|
163
181
|
>
|
|
164
182
|
<view class="menu-text-wrapper">
|
|
@@ -179,7 +197,7 @@ onMounted(() => {
|
|
|
179
197
|
<slot
|
|
180
198
|
name="tile"
|
|
181
199
|
:items="tileItems"
|
|
182
|
-
:goto="
|
|
200
|
+
:goto="handleItemClick"
|
|
183
201
|
:t="languageStore.t"
|
|
184
202
|
/>
|
|
185
203
|
</template>
|