wui-components-v2 1.2.67 → 1.2.68

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.
@@ -260,7 +260,11 @@ function detail() {
260
260
  props.detailButtonHandle(props.data)
261
261
  return
262
262
  }
263
- router.push(`/pages/details-page/index?sourceId=${props.sourceId}&id=${props.code}&title=${props.item.title}`)
263
+ router.push(
264
+ `/pages/details-page/index?sourceId=${encodeURIComponent(props.sourceId)}&id=${encodeURIComponent(
265
+ props.code
266
+ )}&title=${encodeURIComponent(props.item.title || '')}`
267
+ )
264
268
  }
265
269
 
266
270
  // 判断按钮是否满足条件显示
@@ -109,8 +109,11 @@ function goDetail(item: Columns) {
109
109
  return
110
110
  }
111
111
  // 使用字段自身的 sourceId(参考 w-card.vue goto('link'))
112
+ // 参数统一 encodeURIComponent,避免中文/特殊字符在 App 端被截断导致乱码、参数错位
112
113
  uni.navigateTo({
113
- url: `/pages/details-page/index?sourceId=${item.sourceId}&id=${code}&title=${item.title || ''}`,
114
+ url: `/pages/details-page/index?sourceId=${encodeURIComponent(item.sourceId)}&id=${encodeURIComponent(
115
+ String(code)
116
+ )}&title=${encodeURIComponent(item.title || '')}`,
114
117
  })
115
118
  }
116
119
  </script>
@@ -58,18 +58,31 @@ const groups = ref<Groups>({
58
58
  const loading = ref(false)
59
59
  // 折叠面板
60
60
  const collapses = ref()
61
+ /**
62
+ * 安全解码:仅当字符串仍为编码态时解码。
63
+ * H5 / 小程序等平台 onLoad 参数可能已被框架自动解码一次,
64
+ * 对已解码的中文再 decodeURIComponent 会抛 URIError,此处兜底原样返回。
65
+ */
66
+ function safeDecode(value?: string): string {
67
+ if (!value) return ''
68
+ try {
69
+ return decodeURIComponent(value)
70
+ } catch {
71
+ return value
72
+ }
73
+ }
61
74
  onLoad((option: any) => {
62
- sourceId.value = option.sourceId
63
- id.value = option.id
75
+ sourceId.value = safeDecode(option.sourceId)
76
+ id.value = safeDecode(option.id)
64
77
  // #ifdef MP-WEIXIN
65
78
  const q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
66
79
  const sc: any = getQueryParams(q)
67
80
  sourceId.value = sc.sourceId || option.sourceId
68
81
  id.value = sc.id || option.id
69
82
  // #endif
70
- title.value = option.title
83
+ title.value = safeDecode(option.title)
71
84
  uni.setNavigationBarTitle({
72
- title: `${option.title}`,
85
+ title: title.value,
73
86
  })
74
87
  getPageConfig()
75
88
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",