mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-05 18:48:41 +00:00
fix: use $app/state
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { user } from '$lib/stores/user';
|
||||
import { resolve } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { page } from '$app/state';
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem('token');
|
||||
@@ -10,32 +10,35 @@
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
$: currentPath = $page.url.pathname;
|
||||
$: returnParam = currentPath !== '/' ? `?return=${encodeURIComponent($page.url.pathname + $page.url.search)}` : '';
|
||||
$: currentPath = page.url.pathname;
|
||||
$: returnParam =
|
||||
currentPath !== '/' ? `?return=${encodeURIComponent(page.url.pathname + page.url.search)}` : '';
|
||||
</script>
|
||||
|
||||
<div class="fixed top-0 left-0 h-15 w-full bg-neutral-900 z-100">
|
||||
<div class="fixed top-0 left-0 z-100 h-15 w-full bg-neutral-900">
|
||||
<div class="mx-auto flex h-15 max-w-5xl items-center px-4 py-2">
|
||||
<a href={resolve('/')} class="text-xl font-bold text-white hover:text-neutral-300">Sharpbin</a>
|
||||
{#if $user}
|
||||
<div class="ml-auto flex items-center space-x-4">
|
||||
<a
|
||||
href={resolve(`/user/${$user.username}`)}
|
||||
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
|
||||
>Profile</a
|
||||
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Profile</a
|
||||
>
|
||||
<button
|
||||
on:click={logout}
|
||||
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800 cursor-pointer">Logout</button
|
||||
class="cursor-pointer rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
|
||||
>Logout</button
|
||||
>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="ml-auto flex items-center space-x-4">
|
||||
<a href={resolve('/login') + returnParam} class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
|
||||
>Login</a
|
||||
<a
|
||||
href={resolve(`/login${returnParam}`)}
|
||||
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Login</a
|
||||
>
|
||||
<a href={resolve('/register') + returnParam} class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
|
||||
>Register</a
|
||||
<a
|
||||
href={resolve(`/register${returnParam}`)}
|
||||
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Register</a
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user