提交 041dc901 authored 作者: lidongxu's avatar lidongxu

test(login): 测试:登录跳转时如果有查询参数单独提取并拼接

上级 7dd7012f
......@@ -94,6 +94,7 @@ const autoLoginLoading = ref(false) // 自动免登录
const redirect = ref(undefined)
watch(route, (newRoute) => {
console.log('URL 上要跳转的地址', newRoute)
redirect.value = newRoute.query?.redirect
}, { immediate: true })
......@@ -159,7 +160,15 @@ async function loginByType(type, data) {
type,
data
}).then(() => {
router.push({ path: redirect.value || "/" });
console.log('未遂地址跳转', redirect.value)
// 把 redirect.value 上的查询参数拿下来,单独跳转发送如果有的话
const redirectQuery = redirect.value.split('?')[1]
// 字符串转对象结构
const redirectQueryObj = redirectQuery.split('&').reduce((pre, cur) => {
pre[cur.split('=')[0]] = cur.split('=')[1]
return pre
}, {})
router.push({ path: redirect.value || "/", query: redirectQueryObj });
}).catch(() => {
accountPassLoading.value = false;
autoLoginLoading.value = false;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论