wui-components-v2 1.2.67 → 1.2.69
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(
|
|
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=${
|
|
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,38 @@ const groups = ref<Groups>({
|
|
|
58
58
|
const loading = ref(false)
|
|
59
59
|
// 折叠面板
|
|
60
60
|
const collapses = ref()
|
|
61
|
+
/**
|
|
62
|
+
* 安全解码:循环解码直到字符串不再变化或解码失败。
|
|
63
|
+
* 各端 uni.navigateTo 对 URL 参数值的编码次数不一致(H5/App 会在跳转端
|
|
64
|
+
* encodeURIComponent 的基础上再自动编码一次,onLoad 收到双重编码值),
|
|
65
|
+
* 这里循环解码到稳定态,兼容 0/1/2 层编码,保证拿到明文。
|
|
66
|
+
*/
|
|
67
|
+
function safeDecode(value?: string): string {
|
|
68
|
+
if (!value) return ''
|
|
69
|
+
let result = value
|
|
70
|
+
while (result.includes('%')) {
|
|
71
|
+
try {
|
|
72
|
+
const decoded = decodeURIComponent(result)
|
|
73
|
+
if (decoded === result) break
|
|
74
|
+
result = decoded
|
|
75
|
+
} catch {
|
|
76
|
+
break
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return result
|
|
80
|
+
}
|
|
61
81
|
onLoad((option: any) => {
|
|
62
|
-
sourceId.value = option.sourceId
|
|
63
|
-
id.value = option.id
|
|
82
|
+
sourceId.value = safeDecode(option.sourceId)
|
|
83
|
+
id.value = safeDecode(option.id)
|
|
64
84
|
// #ifdef MP-WEIXIN
|
|
65
85
|
const q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
|
|
66
86
|
const sc: any = getQueryParams(q)
|
|
67
87
|
sourceId.value = sc.sourceId || option.sourceId
|
|
68
88
|
id.value = sc.id || option.id
|
|
69
89
|
// #endif
|
|
70
|
-
title.value = option.title
|
|
90
|
+
title.value = safeDecode(option.title)
|
|
71
91
|
uni.setNavigationBarTitle({
|
|
72
|
-
title:
|
|
92
|
+
title: title.value,
|
|
73
93
|
})
|
|
74
94
|
getPageConfig()
|
|
75
95
|
})
|
|
@@ -389,23 +389,43 @@ async function batchAction(item: rowActions) {
|
|
|
389
389
|
}
|
|
390
390
|
// 优先使用 props 传入的 sourceId,未传则走 onLoad 路由获取
|
|
391
391
|
const internalSourceId = ref(props.sourceId)
|
|
392
|
+
/**
|
|
393
|
+
* 安全解码:循环解码直到字符串不再变化或解码失败。
|
|
394
|
+
* 各端 uni.navigateTo 对 URL 参数值的编码次数不一致(H5/App 会在跳转端
|
|
395
|
+
* encodeURIComponent 的基础上再自动编码一次,onLoad 收到双重编码值),
|
|
396
|
+
* 这里循环解码到稳定态,兼容 0/1/2 层编码,保证拿到明文。
|
|
397
|
+
*/
|
|
398
|
+
function safeDecode(value?: string | number): string {
|
|
399
|
+
if (value === undefined || value === null) return ''
|
|
400
|
+
let result = String(value)
|
|
401
|
+
while (result.includes('%')) {
|
|
402
|
+
try {
|
|
403
|
+
const decoded = decodeURIComponent(result)
|
|
404
|
+
if (decoded === result) break
|
|
405
|
+
result = decoded
|
|
406
|
+
} catch {
|
|
407
|
+
break
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return result
|
|
411
|
+
}
|
|
392
412
|
onLoad((option: any) => {
|
|
393
413
|
// 如果 props 没传 sourceId,则从路由参数获取
|
|
394
414
|
if (!internalSourceId.value) {
|
|
395
|
-
internalSourceId.value = option.sourceId
|
|
415
|
+
internalSourceId.value = safeDecode(option.sourceId)
|
|
396
416
|
}
|
|
397
|
-
pageTitle.value = option.title
|
|
417
|
+
pageTitle.value = safeDecode(option.title)
|
|
398
418
|
pageType.value = option.pageType
|
|
399
419
|
mainCode.value = option.mainCode || ''
|
|
400
420
|
menuId.value = option.menuId || ''
|
|
401
421
|
uni.setNavigationBarTitle({
|
|
402
|
-
title:
|
|
422
|
+
title: pageTitle.value,
|
|
403
423
|
})
|
|
404
424
|
// 解析 URL 中 c_* 参数作为筛选字段默认值(c_{sourceId}={value})
|
|
405
425
|
const criteria: { [key: string]: any } = {}
|
|
406
426
|
Object.keys(option || {}).forEach(key => {
|
|
407
427
|
if (key.startsWith('c_')) {
|
|
408
|
-
criteria[key.slice(2)] = option[key]
|
|
428
|
+
criteria[key.slice(2)] = safeDecode(option[key])
|
|
409
429
|
}
|
|
410
430
|
})
|
|
411
431
|
urlDefaultCriteria.value = criteria
|