fix(路由): 清除URL中的token参数并保留其他查询参数
当URL中包含token参数时,自动清除该参数并保留其他查询参数,防止token暴露在URL中
This commit is contained in:
parent
d25f87a889
commit
3ab1dfae30
|
|
@ -149,6 +149,16 @@ onMounted(async (e) => {
|
||||||
Session.set("token", res.data.token);
|
Session.set("token", res.data.token);
|
||||||
Session.set("userPhone", res.data.phone);
|
Session.set("userPhone", res.data.phone);
|
||||||
|
|
||||||
|
// 解构路由参数,排除token
|
||||||
|
const { token, ...otherQuery } = route.query;
|
||||||
|
// 若存在token,替换路由清除参数
|
||||||
|
if (token) {
|
||||||
|
router.replace({
|
||||||
|
path: route.path, // 保持当前路径不变
|
||||||
|
query: otherQuery, // 保留其他参数
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue