mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-17 23:48:45 +00:00
Store 초기화를 hooks.client.ts에서 수행하도록 변경
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { goto as svelteGoto } from "$app/navigation";
|
||||
import { clientKeyStore, masterKeyStore } from "$lib/stores";
|
||||
import "../app.css";
|
||||
import { prepareClientKeyStore, prepareMasterKeyStore } from "./services";
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
onMount(async () => {
|
||||
const redirect = async (url: string) => {
|
||||
const goto = async (url: string) => {
|
||||
const whitelist = ["/auth", "/key", "/client/pending"];
|
||||
if (!whitelist.some((path) => location.pathname.startsWith(path))) {
|
||||
await goto(`${url}?redirect=${encodeURIComponent(location.pathname + location.search)}`);
|
||||
await svelteGoto(
|
||||
`${url}?redirect=${encodeURIComponent(location.pathname + location.search)}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if (!(await prepareClientKeyStore())) {
|
||||
return await redirect("/key/generate");
|
||||
}
|
||||
if (!(await prepareMasterKeyStore())) {
|
||||
return await redirect("/client/pending");
|
||||
if (!$clientKeyStore) {
|
||||
await goto("/key/generate");
|
||||
} else if (!$masterKeyStore) {
|
||||
await goto("/client/pending");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user