🦀️ fix: 新增路径参数截取方式

This commit is contained in:
wangsongsole 2024-03-07 10:55:48 +08:00
parent 4697a5cfb5
commit 7f44aeecd4
1 changed files with 20 additions and 1 deletions

View File

@ -126,7 +126,7 @@
if (openid) {
localStorage.setItem('openid', openid);
/* 截取openid防止重定向 */
this.entryLink = location.href.replace(/&[^&]*$/, '');
this.entryLink = this.removeLastParamFromUrl(location.href);
} else {
this.entryLink = location.href;
}
@ -224,6 +224,25 @@
},
},
methods: {
// 截取路径上的最后一个参数的函数
removeLastParamFromUrl (url) {
// 找到问号后的路径部分
var pathIndex = url.indexOf('?');
var path = url.substring(pathIndex + 1);
// 将路径部分拆分为参数数组
var params = path.split('&');
// 如果存在参数,移除最后一个参数
if (params.length > 0) {
params.pop(); // 移除最后一个参数
}
// 重构URL
var updatedUrl = url.substring(0, pathIndex + 1) + params.join('&');
return updatedUrl;
},
//获取白名单验证码
getcode () {