forked from Mirrors/elk
fix: router
This commit is contained in:
parent
313cafa23c
commit
b980d519d5
2 changed files with 13 additions and 4 deletions
|
@ -47,8 +47,9 @@ async function oauth() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function explore() {
|
async function explore() {
|
||||||
masto.loginTo({ server, guestOnly: true })
|
await masto.loginTo({ server, guest: true })
|
||||||
|
isSigninDialogOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleInput() {
|
async function handleInput() {
|
||||||
|
|
|
@ -89,6 +89,8 @@ async function loginTo({ server, token, vapidKey, pushSubscription, guest = fals
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
const oldServer = currentUser.value.server
|
||||||
|
|
||||||
let user: UserLogin | undefined = token
|
let user: UserLogin | undefined = token
|
||||||
? users.value.find(u => u.server === server && u.token === token)
|
? users.value.find(u => u.server === server && u.token === token)
|
||||||
: ((guest
|
: ((guest
|
||||||
|
@ -150,11 +152,17 @@ async function loginTo({ server, token, vapidKey, pushSubscription, guest = fals
|
||||||
currentUserId.value = getUniqueUserId(user)
|
currentUserId.value = getUniqueUserId(user)
|
||||||
|
|
||||||
// This only cleans up the URL; page content should stay the same
|
// This only cleans up the URL; page content should stay the same
|
||||||
if (route.path === '/signin/callback') {
|
if (!user.guest && (route.path === '/signin/callback' || route.path === '/')) {
|
||||||
await router.push('/home')
|
await router.push('/home')
|
||||||
}
|
}
|
||||||
|
else if (isGuest.value && route.meta.middleware === 'auth') {
|
||||||
|
await router.push(`/${server}/public`)
|
||||||
|
}
|
||||||
else if ('server' in route.params && user.server !== route.params.server) {
|
else if ('server' in route.params && user.server !== route.params.server) {
|
||||||
|
if (!route.params.account.includes('@'))
|
||||||
|
// convert to long handle
|
||||||
|
route.params.account += `@${oldServer}`
|
||||||
|
|
||||||
await router.push({
|
await router.push({
|
||||||
...route,
|
...route,
|
||||||
params: {
|
params: {
|
||||||
|
|
Loading…
Reference in a new issue