-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.vue
77 lines (61 loc) · 1.55 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script setup lang="ts">
const { name, author } = useAppConfig();
const { loggedIn, fetch: refreshSession, clear } = useUserSession();
const authModalIsOpen = ref(false);
const createNoteModalIsOpen = ref(false);
const router = useRouter();
const { loading, password, login } = useLogin();
const { loading: creating, title, slug, create } = useNoteCreate();
const handleAuthModal = () => {
authModalIsOpen.value = true;
};
const handleCreateNoteModal = () => {
createNoteModalIsOpen.value = true;
};
const handleLogin = async (pass: string) => {
password.value = pass;
await login();
await refreshSession();
authModalIsOpen.value = false;
};
const handleNewNote = async (name: string) => {
title.value = name;
await create();
createNoteModalIsOpen.value = false;
router.push(`/note/${slug.value}`);
};
useSeoMeta({
ogSiteName: name,
ogType: "website",
twitterCard: "summary_large_image",
twitterSite: author.twitter,
});
</script>
<template>
<UContainer>
<Header
:title="name"
:is-logged="loggedIn"
@new="handleCreateNoteModal"
@logout="clear"
@login="handleAuthModal"
/>
<AuthModal
v-model="authModalIsOpen"
:loading="loading"
@login="handleLogin"
/>
<NewNoteModal
v-model="createNoteModalIsOpen"
:loading="creating"
@new="handleNewNote"
>
</NewNoteModal>
<NuxtLoadingIndicator color="cyan" />
<div class="w-full pb-48">
<NuxtPage />
</div>
<Footer :twitter="author.twitter" />
<UNotifications />
</UContainer>
</template>