wui-components-v2 1.2.68 → 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.
|
@@ -59,17 +59,24 @@ const loading = ref(false)
|
|
|
59
59
|
// 折叠面板
|
|
60
60
|
const collapses = ref()
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* 安全解码:循环解码直到字符串不再变化或解码失败。
|
|
63
|
+
* 各端 uni.navigateTo 对 URL 参数值的编码次数不一致(H5/App 会在跳转端
|
|
64
|
+
* encodeURIComponent 的基础上再自动编码一次,onLoad 收到双重编码值),
|
|
65
|
+
* 这里循环解码到稳定态,兼容 0/1/2 层编码,保证拿到明文。
|
|
65
66
|
*/
|
|
66
67
|
function safeDecode(value?: string): string {
|
|
67
68
|
if (!value) return ''
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
}
|
|
72
78
|
}
|
|
79
|
+
return result
|
|
73
80
|
}
|
|
74
81
|
onLoad((option: any) => {
|
|
75
82
|
sourceId.value = safeDecode(option.sourceId)
|
|
@@ -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
|