-
-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sign-out and empty content (#1654)
- Loading branch information
Showing
1 changed file
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import type { RouteLocationNormalized } from 'vue-router' | ||
|
||
export default defineNuxtRouteMiddleware((to) => { | ||
if (process.server) | ||
return | ||
|
||
if (to.path === '/signin/callback') | ||
return | ||
|
||
onHydrated(() => { | ||
if (!currentUser.value) { | ||
if (to.path === '/home' && to.query['share-target'] !== undefined) | ||
return navigateTo('/share-target') | ||
else | ||
return navigateTo(`/${currentServer.value}/public/local`) | ||
} | ||
if (to.path === '/') | ||
return navigateTo('/home') | ||
}) | ||
if (isHydrated.value) | ||
return handleAuth(to) | ||
|
||
onHydrated(() => handleAuth(to)) | ||
}) | ||
|
||
function handleAuth(to: RouteLocationNormalized) { | ||
if (!currentUser.value) { | ||
if (to.path === '/home' && to.query['share-target'] !== undefined) | ||
return navigateTo('/share-target') | ||
else | ||
return navigateTo(`/${currentServer.value}/public/local`) | ||
} | ||
if (to.path === '/') | ||
return navigateTo('/home') | ||
} |