优化未登录访问需要登录的资源,在登录后重定向丢失请求参数问题

This commit is contained in:
不做码农 2023-11-26 12:27:13 +08:00
parent e1879c706c
commit 43485dddfa

View File

@ -143,7 +143,14 @@ function handleLogin() {
.login(loginForm.value) .login(loginForm.value)
.then(() => { .then(() => {
proxy.$modal.msgSuccess(proxy.$t('login.loginSuccess')) proxy.$modal.msgSuccess(proxy.$t('login.loginSuccess'))
router.push({ path: redirect.value || '/' }) const query = route.query
const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
if (cur !== 'redirect') {
acc[cur] = query[cur]
}
return acc
}, {})
router.push({ path: redirect.value || '/', query: otherQueryParams })
}) })
.catch((error) => { .catch((error) => {
console.error(error) console.error(error)