rano/web/routes/+layout.svelte

25 lines
635 B
Svelte
Raw Normal View History

2024-11-01 23:19:56 +05:30
<script lang="ts">
import { beforeNavigate } from '$app/navigation';
import { updated } from '$app/stores';
2024-11-01 23:19:56 +05:30
import { setContextClient } from '@urql/svelte';
import { newClient } from '$lib/gql/client';
2024-11-17 22:28:29 +05:30
import { Me } from '$lib/gql/account.gql';
2024-11-01 23:19:56 +05:30
import '../app.css';
const { children } = $props();
2024-11-17 22:28:29 +05:30
const host = import.meta.env.VITE_GRAPH_URL ?? '';
const client = newClient(`${host}/query`);
setContextClient(client);
beforeNavigate(({ willUnload, to }) => {
if ($updated && !willUnload && to?.url) {
location.href = to.url.href;
}
});
const p = client.query(Me, {}).toPromise();
</script>
{@render children()}