diff options
| author | Fuwn <[email protected]> | 2023-12-07 03:21:46 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-07 03:21:46 -0800 |
| commit | 05af101cc2e71567c0e2975a2362787ccb5892e4 (patch) | |
| tree | 925dd934b2d4eacd68c2b202bd82c023f901d364 /src/routes/user | |
| parent | feat(settings): label for method (diff) | |
| download | due.moe-05af101cc2e71567c0e2975a2362787ccb5892e4.tar.xz due.moe-05af101cc2e71567c0e2975a2362787ccb5892e4.zip | |
feat(user): default user page
Diffstat (limited to 'src/routes/user')
| -rw-r--r-- | src/routes/user/+page.svelte | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/routes/user/+page.svelte b/src/routes/user/+page.svelte new file mode 100644 index 00000000..b6c63f35 --- /dev/null +++ b/src/routes/user/+page.svelte @@ -0,0 +1,22 @@ +<script lang="ts"> + import { browser } from '$app/environment'; + import { goto } from '$app/navigation'; + import type { UserIdentity } from '$lib/AniList/identity'; + import { onMount } from 'svelte'; + import { env } from '$env/dynamic/public'; + + const user = + browser && localStorage.getItem('userIdentity') + ? (JSON.parse(localStorage.getItem('userIdentity') || '') as UserIdentity).name + : null; + + onMount(() => { + if (user) { + goto(`/user/${user}`); + } else { + goto( + `https://anilist.co/api/v2/oauth/authorize?client_id=${env.PUBLIC_ANILIST_CLIENT_ID}&redirect_uri=${env.PUBLIC_ANILIST_REDIRECT_URI}&response_type=code` + ); + } + }); +</script> |