fix(util): 调整参数合并顺序并修复透传参数问题
1. 调整appendQueryParams的参数合并顺序,将page_params放在最后 2. 修复redirectTo调用时的参数透传问题,正确保留title和enable_set_title参数 3. 添加redirectTo跳转时的调试日志
This commit is contained in:
@@ -765,6 +765,8 @@ export default {
|
||||
// 替换url中的前缀
|
||||
url = adaptSubpackageUrl(url);
|
||||
|
||||
console.log('[redirectTo] to=', to, 'param=', param, '-> url=', url);
|
||||
|
||||
// 针对tabBar.list中的路径,直接切换tabBar
|
||||
for (let i = 0; i < systemTabBarList.length; i++) {
|
||||
const tabBarUrl = systemTabBarList[i];
|
||||
@@ -1324,13 +1326,14 @@ export default {
|
||||
if (link.wap_url && link.wap_url.indexOf('http') != -1) {
|
||||
// 公共参数 + 透传 page_params(resolveLinkUrl 已把 wap_url 中的 query 合并到 page_params)
|
||||
const pageParams = (link.page_params && typeof link.page_params === 'object') ? link.page_params : {};
|
||||
// page_params 放在最后,确保其在最终 URL 中位于 title/enable_set_title 之后
|
||||
const params = Object.assign(
|
||||
{},
|
||||
pageParams,
|
||||
{
|
||||
title: link?.title ?? '',
|
||||
enable_set_title: link?.enable_set_title ? 1 : 0
|
||||
}
|
||||
},
|
||||
pageParams
|
||||
);
|
||||
let url = this.normalizeUrl(decodeEntity(link.wap_url));
|
||||
url = this.appendQueryParams(url, params);
|
||||
@@ -1445,8 +1448,14 @@ export default {
|
||||
} else if (link.wap_url) { // 微页面/内部页面
|
||||
// resolveLinkUrl 已把 wap_url 中的 query 合并到 link.page_params
|
||||
// 这里过滤掉 link 元数据字段, 避免 wap_url/name/parent/title 等被错误附加到目标 URL
|
||||
const { wap_url, name, parent, title, enable_set_title, type, appid, page, mobile, image, ...navParams } = link;
|
||||
this.redirectTo(link.wap_url, { ...navParams, ...(link.page_params || {}) });
|
||||
// title/enable_set_title/page_params 仍需透传到目标 URL,page_params 放最后
|
||||
const { wap_url, name, parent, type, appid, page, mobile, image, ...navParams } = link;
|
||||
this.redirectTo(link.wap_url, {
|
||||
...navParams,
|
||||
title: link?.title ?? '',
|
||||
enable_set_title: link?.enable_set_title ? 1 : 0,
|
||||
...(link.page_params || {})
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user