wui-components-v2 1.1.62 → 1.1.63

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.
@@ -21,7 +21,7 @@ const props = defineProps({
21
21
  },
22
22
  load: {
23
23
  type: Function as PropType<() => void>,
24
- default: () => { },
24
+ default: () => {},
25
25
  },
26
26
  menuTopType: {
27
27
  type: String,
@@ -35,9 +35,7 @@ interface Icon {
35
35
  id: string
36
36
  path: string
37
37
  }
38
- const {
39
- currentThemeColor,
40
- } = useManualTheme()
38
+ const { currentThemeColor } = useManualTheme()
41
39
  const { generateRandomColor } = useColorGenerator(currentThemeColor.value.primary)
42
40
  const menuList = ref([])
43
41
  const title = ref('')
@@ -54,8 +52,7 @@ const paging = ref()
54
52
  // 点击菜单跳转页面
55
53
  function gotoPage(item: any) {
56
54
  // 跳转页面
57
- if (goto(item))
58
- return
55
+ if (goto(item)) return
59
56
  // 打开动作面板
60
57
  openSheet(item)
61
58
  }
@@ -63,8 +60,7 @@ function gotoPage(item: any) {
63
60
  // 点击动作面板跳转页面
64
61
  function sheetGotoPage(item: any) {
65
62
  // 跳转页面
66
- if (goto(item))
67
- return
63
+ if (goto(item)) return
68
64
  // 打开动作面板
69
65
  openSheet(item, 300)
70
66
  }
@@ -86,7 +82,6 @@ function goto(item: any) {
86
82
  return true
87
83
 
88
84
  default:
89
-
90
85
  return false
91
86
  }
92
87
  }
@@ -123,8 +118,7 @@ function openSheet(item: any, s = 0) {
123
118
  function filterHiddenTree(tree: any, childKey = 'children', deepClone = false) {
124
119
  // 深拷贝处理(可选)
125
120
  const clone = (data: any) => {
126
- if (!deepClone)
127
- return data
121
+ if (!deepClone) return data
128
122
  return JSON.parse(JSON.stringify(data))
129
123
  }
130
124
 
@@ -153,23 +147,22 @@ onShow(() => {
153
147
  // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用this.$refs.paging.reload()即可
154
148
  function queryList() {
155
149
  // 此处请求仅为演示,请替换为自己项目中的请求
156
- menu().then((res: any) => {
157
- // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
158
- if (!res?.blocks.length) {
159
- toast.warning('暂无权限,请重新登录或联系管理员')
160
- setTimeout(() => {
161
- router.replaceAll('/pages/login/index')
162
- }, 1000)
163
- }
164
- uni.setNavigationBarTitle({ title: res?.programName || '' })// 设置标题
165
- paging.value.complete(res?.blocks || [])
166
- }).catch((res: any) => {
167
- // 如果请求失败写this.$refs.paging.complete(false),会自动展示错误页面
168
- // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
169
- // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
170
- console.log(res, 'menu error')
171
- paging.value.complete(false)
172
- })
150
+ menu()
151
+ .then((res: any) => {
152
+ // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
153
+ if (!res?.blocks.length) {
154
+ toast.warning('暂无权限,请重新登录或联系管理员')
155
+ }
156
+ uni.setNavigationBarTitle({ title: res?.programName || '' }) // 设置标题
157
+ paging.value.complete(res?.blocks || [])
158
+ })
159
+ .catch((res: any) => {
160
+ // 如果请求失败写this.$refs.paging.complete(false),会自动展示错误页面
161
+ // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
162
+ // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
163
+ console.log(res, 'menu error')
164
+ paging.value.complete(false)
165
+ })
173
166
  }
174
167
  </script>
175
168
 
@@ -186,15 +179,28 @@ function queryList() {
186
179
  <view class="border-rd-2 bg-white pa-1 dark:bg-[var(--wot-dark-background2)]">
187
180
  <wd-grid :column="4" clickable>
188
181
  <wd-grid-item
189
- v-for="(subItem, subIndex) in item.items" :key="subIndex" use-text-slot use-icon-slot
182
+ v-for="(subItem, subIndex) in item.items"
183
+ :key="subIndex"
184
+ use-text-slot
185
+ use-icon-slot
190
186
  @itemclick="gotoPage(subItem)"
191
187
  >
192
188
  <template #icon>
193
- <view class="flex items-center justify-center rounded-2" :style="{ backgroundColor: desaturateColor(subItem.color, 0.25), height: '80rpx', width: '80rpx' }">
189
+ <view
190
+ class="flex items-center justify-center rounded-2"
191
+ :style="{ backgroundColor: desaturateColor(subItem.color, 0.25), height: '80rpx', width: '80rpx' }"
192
+ >
194
193
  <!-- <text class="i-carbon:chart-combo-stacked text-center text-5"
195
194
  :class="[props.icons.find(item => item.id === subItem.id)?.path]"
196
195
  :style="{ color:desaturateColor(subItem.color,0.5) }" /> -->
197
- <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" width="80" height="80" viewBox="0 0 80 80"><g fill="none" stroke-linecap="round" stroke-width="4"><rect width="24" height="24" x="12" y="12" fill="#9b51e0" stroke="#9b51e0" rx="4" /><rect width="24" height="24" x="44" y="12" fill="#56ccf2" stroke="#56ccf2" rx="4" /><rect width="24" height="24" x="12" y="44" fill="#56ccf2" stroke="#56ccf2" rx="4" /><rect width="24" height="24" x="44" y="44" fill="#9b51e0" stroke="#9b51e0" rx="4" /></g></svg>
196
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" width="80" height="80" viewBox="0 0 80 80">
197
+ <g fill="none" stroke-linecap="round" stroke-width="4">
198
+ <rect width="24" height="24" x="12" y="12" fill="#9b51e0" stroke="#9b51e0" rx="4" />
199
+ <rect width="24" height="24" x="44" y="12" fill="#56ccf2" stroke="#56ccf2" rx="4" />
200
+ <rect width="24" height="24" x="12" y="44" fill="#56ccf2" stroke="#56ccf2" rx="4" />
201
+ <rect width="24" height="24" x="44" y="44" fill="#9b51e0" stroke="#9b51e0" rx="4" />
202
+ </g>
203
+ </svg>
198
204
  </view>
199
205
  </template>
200
206
  <template #text>
@@ -217,8 +223,15 @@ function queryList() {
217
223
  </template>
218
224
  </z-paging>
219
225
  <wd-action-sheet
220
- v-model="sheetShow" :z-index="9999" :actions="actions" :title="title"
221
- @select="({ item }) => { sheetGotoPage(item) }"
226
+ v-model="sheetShow"
227
+ :z-index="9999"
228
+ :actions="actions"
229
+ :title="title"
230
+ @select="
231
+ ({ item }) => {
232
+ sheetGotoPage(item)
233
+ }
234
+ "
222
235
  />
223
236
  </template>
224
237
 
@@ -50,10 +50,7 @@ const {
50
50
  onMounted(() => {
51
51
  getThemeConfig().then(res => {
52
52
  if (res.status == 'success') {
53
- themeConfig.value = {
54
- ...res.themeConfig,
55
- showHomePage: false,
56
- }
53
+ themeConfig.value = res.themeConfig
57
54
  }
58
55
  })
59
56
  })
@@ -17,19 +17,17 @@ const toast = useGlobalToast()
17
17
 
18
18
  function queryList() {
19
19
  // 此处请求仅为演示,请替换为自己项目中的请求
20
- menu().then((res: any) => {
21
- if (!res?.blocks?.length) {
22
- toast.warning('暂无权限,请重新登录或联系管理员')
23
- setTimeout(() => {
24
- router.replaceAll('/pages/login/index')
25
- }, 1000)
26
- }
27
- else {
28
- menuList.value = res?.blocks
29
- }
30
- }).catch((res: any) => {
31
- console.log(res)
32
- })
20
+ menu()
21
+ .then((res: any) => {
22
+ if (!res?.blocks?.length) {
23
+ toast.warning('暂无权限,请重新登录或联系管理员')
24
+ } else {
25
+ menuList.value = res?.blocks
26
+ }
27
+ })
28
+ .catch((res: any) => {
29
+ console.log(res)
30
+ })
33
31
  }
34
32
 
35
33
  /**
@@ -38,10 +36,7 @@ function queryList() {
38
36
  * @param childrenKey - 子节点的键名,默认为 'children'
39
37
  * @returns 最深层节点组成的数组
40
38
  */
41
- function extractDeepestNodes<T>(
42
- treeData: T[],
43
- childrenKey: string = 'children',
44
- ): T[] {
39
+ function extractDeepestNodes<T>(treeData: T[], childrenKey: string = 'children'): T[] {
45
40
  const result: T[] = []
46
41
 
47
42
  /**
@@ -55,8 +50,7 @@ function extractDeepestNodes<T>(
55
50
  if (children && Array.isArray(children) && children.length > 0) {
56
51
  // 如果有子节点,继续深入
57
52
  traverse(children, depth + 1)
58
- }
59
- else {
53
+ } else {
60
54
  // 如果没有子节点,这是最深层的节点,添加到结果中
61
55
  result.push(node)
62
56
  }
@@ -80,19 +74,16 @@ const filteredMenus = computed<MenuItem[]>(() => {
80
74
  return a.value
81
75
  }
82
76
  const query = searchQuery.value.toLowerCase().trim()
83
- return a.value.filter(menu =>
84
- menu.title.toLowerCase().includes(query)
85
- || (menu.tip && menu.tip.toLowerCase().includes(query)),
77
+ return a.value.filter(
78
+ menu => menu.title.toLowerCase().includes(query) || (menu.tip && menu.tip.toLowerCase().includes(query))
86
79
  )
87
80
  })
88
81
 
89
82
  function highlightedLabel(menu: MenuItem) {
90
- if (!searchQuery.value.trim())
91
- return menu.title
83
+ if (!searchQuery.value.trim()) return menu.title
92
84
  const query = searchQuery.value.toLowerCase().trim()
93
85
  const index = menu.title.toLowerCase().indexOf(query)
94
- if (index === -1)
95
- return menu.title
86
+ if (index === -1) return menu.title
96
87
  const before = menu.title.substring(0, index)
97
88
  const match = menu.title.substring(index, index + query.length)
98
89
  const after = menu.title.substring(index + query.length)
@@ -116,8 +107,7 @@ function handleMenuClick(menu: MenuItem) {
116
107
  }
117
108
 
118
109
  function addToHistory(keyword: string) {
119
- if (!keyword.trim())
120
- return
110
+ if (!keyword.trim()) return
121
111
  const current = [...searchHistory.value]
122
112
  const index = current.indexOf(keyword)
123
113
  if (index > -1) {
@@ -141,8 +131,7 @@ onMounted(() => {
141
131
  if (saved) {
142
132
  try {
143
133
  searchHistory.value = JSON.parse(saved)
144
- }
145
- catch {
134
+ } catch {
146
135
  searchHistory.value = []
147
136
  }
148
137
  }
@@ -160,7 +149,7 @@ onMounted(() => {
160
149
  type="text"
161
150
  placeholder="搜索菜单、功能..."
162
151
  class="ml-2 flex-1 bg-transparent text-base text-slate-800 outline-none placeholder:text-slate-400"
163
- >
152
+ />
164
153
  <view
165
154
  v-if="searchQuery"
166
155
  class="cursor-pointer rounded-full p-1 transition-colors hover:bg-slate-200"
@@ -173,15 +162,10 @@ onMounted(() => {
173
162
  </view>
174
163
 
175
164
  <view class="px-4 pb-4">
176
- <SearchHistory
177
- v-model="searchHistory"
178
- @select="handleSelectHistory"
179
- />
165
+ <SearchHistory v-model="searchHistory" @select="handleSelectHistory" />
180
166
 
181
167
  <view v-if="filteredMenus.length === 0" class="mt-6">
182
- <p class="text-center text-sm text-slate-400">
183
- 未找到相关菜单
184
- </p>
168
+ <p class="text-center text-sm text-slate-400">未找到相关菜单</p>
185
169
  </view>
186
170
 
187
171
  <view v-else class="mt-4">
@@ -207,10 +191,7 @@ onMounted(() => {
207
191
  <wd-icon name="picture" size="22px" color="#FFF" />
208
192
  </view>
209
193
  <view class="flex-1 text-left">
210
- <p
211
- class="text-base text-slate-800 font-medium"
212
- v-html="highlightedLabel(menu)"
213
- />
194
+ <p class="text-base text-slate-800 font-medium" v-html="highlightedLabel(menu)" />
214
195
  <p v-if="menu.tip" class="mt-0.5 text-xs text-slate-400">
215
196
  {{ menu.tip }}
216
197
  </p>
@@ -26,9 +26,7 @@ export interface MenuItem {
26
26
  export function useMenus(props?: Props, pagingRef?: Ref<any>) {
27
27
  const router = useRouter()
28
28
  const toast = useGlobalToast()
29
- const {
30
- currentThemeColor,
31
- } = useManualTheme()
29
+ const { currentThemeColor } = useManualTheme()
32
30
  const colorGenerator = new RainbowColorGenerator()
33
31
  const menuList = ref<MenuItem[]>([])
34
32
  const title = ref('')
@@ -44,18 +42,16 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
44
42
  const actions = ref([])
45
43
  // 点击菜单跳转页面
46
44
  function gotoPage(item: MenuItem) {
47
- // 跳转页面
48
- if (goto(item))
49
- return
45
+ // 跳转页面
46
+ if (goto(item)) return
50
47
  // 打开动作面板
51
48
  openSheet(item)
52
49
  }
53
50
 
54
51
  // 点击动作面板跳转页面
55
52
  function sheetGotoPage(item: MenuItem) {
56
- // 跳转页面
57
- if (goto(item))
58
- return
53
+ // 跳转页面
54
+ if (goto(item)) return
59
55
  // 打开动作面板
60
56
  openSheet(item, 300)
61
57
  }
@@ -72,13 +68,12 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
72
68
  router.push(`/pages/tree-page/index?sourceId=${item.id}&title=${item.title}`)
73
69
  return true
74
70
  case '报表':
75
- // uni.navigateTo({
76
- // url: `/pages/report-table/report-table?sourceId=${item.id}&title=${item.title}`,
77
- // })
71
+ // uni.navigateTo({
72
+ // url: `/pages/report-table/report-table?sourceId=${item.id}&title=${item.title}`,
73
+ // })
78
74
  return true
79
75
 
80
76
  default:
81
-
82
77
  return false
83
78
  }
84
79
  }
@@ -113,17 +108,16 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
113
108
  * @returns {Array} 过滤后的新树形数据
114
109
  */
115
110
  function filterHiddenTree(tree: any, childKey = 'children', deepClone = false) {
116
- // 深拷贝处理(可选)
111
+ // 深拷贝处理(可选)
117
112
  const clone = (data: any) => {
118
- if (!deepClone)
119
- return data
113
+ if (!deepClone) return data
120
114
  return JSON.parse(JSON.stringify(data))
121
115
  }
122
116
 
123
117
  return clone(tree)
124
118
  .filter((node: any) => !node.disabled) // 过滤当前层隐藏节点
125
119
  .map((node: any) => {
126
- // 递归处理子节点
120
+ // 递归处理子节点
127
121
  if (Array.isArray(node[childKey])) {
128
122
  node[childKey] = filterHiddenTree(node[childKey], childKey, deepClone)
129
123
  }
@@ -141,31 +135,30 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
141
135
 
142
136
  // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用this.$refs.paging.reload()即可
143
137
  function queryList() {
144
- // 此处请求仅为演示,请替换为自己项目中的请求
145
- menu().then((res: any) => {
146
- // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
147
- if (!res?.blocks?.length) {
148
- toast.warning('暂无权限,请重新登录或联系管理员')
149
- setTimeout(() => {
150
- router.replaceAll('/pages/login/index')
151
- }, 1000)
152
- }
153
- navTitle.value = res?.programName || ''
154
- uni.setNavigationBarTitle({ title: res?.programName || '' })// 设置标题
155
- pagingRef?.value.complete(res?.blocks || [])
156
- }).catch((res: any) => {
157
- console.log(res)
158
- // 如果请求失败写this.$refs.paging.complete(false),会自动展示错误页面
159
- // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
160
- // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
161
- pagingRef?.value.complete(false)
162
- })
138
+ // 此处请求仅为演示,请替换为自己项目中的请求
139
+ menu()
140
+ .then((res: any) => {
141
+ // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
142
+ if (!res?.blocks?.length) {
143
+ toast.warning('暂无权限,请重新登录或联系管理员')
144
+ }
145
+ navTitle.value = res?.programName || ''
146
+ uni.setNavigationBarTitle({ title: res?.programName || '' }) // 设置标题
147
+ pagingRef?.value.complete(res?.blocks || [])
148
+ })
149
+ .catch((res: any) => {
150
+ console.log(res)
151
+ // 如果请求失败写this.$refs.paging.complete(false),会自动展示错误页面
152
+ // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
153
+ // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
154
+ pagingRef?.value.complete(false)
155
+ })
163
156
  }
164
157
 
165
158
  // 快速访问菜单
166
159
  const sectionmenu = ref<MenuItem[]>([])
167
160
  const filersectiomenus = computed(() => {
168
- // 截取数组前4项
161
+ // 截取数组前4项
169
162
  return sectionmenu.value.slice(0, 4)
170
163
  })
171
164
 
@@ -174,12 +167,10 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
174
167
  const res = await fastmenu()
175
168
  if (res.fastMenu) {
176
169
  sectionmenu.value = res.fastMenu.QuickQueryBar || []
177
- }
178
- else {
170
+ } else {
179
171
  sectionmenu.value = []
180
172
  }
181
- }
182
- catch (error) {
173
+ } catch (error) {
183
174
  console.log(error)
184
175
  }
185
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.62",
3
+ "version": "1.1.63",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",