forked from dullage/flatnotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.vue
More file actions
92 lines (80 loc) · 2.37 KB
/
App.vue
File metadata and controls
92 lines (80 loc) · 2.37 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<template>
<LoadingIndicator
ref="loadingIndicator"
class="container mx-auto flex h-screen flex-col px-2 py-4 print:max-w-full"
>
<PrimeToast />
<SearchModal v-model="isSearchModalVisible" />
<NavBar
v-if="showNavBar"
ref="navBar"
:class="{ 'print:hidden': route.name == 'note' }"
:hide-logo="!showNavBarLogo"
@toggleSearchModal="toggleSearchModal"
/>
<RouterView />
</LoadingIndicator>
</template>
<script setup>
import Mousetrap from "mousetrap";
import "mousetrap/plugins/global-bind/mousetrap-global-bind";
import { useToast } from "primevue/usetoast";
import { computed, ref } from "vue";
import { RouterView, useRoute } from "vue-router";
import { apiErrorHandler, getConfig } from "./api.js";
import PrimeToast from "./components/PrimeToast.vue";
import { useGlobalStore } from "./globalStore.js";
import { loadTheme } from "./helpers.js";
import NavBar from "./partials/NavBar.vue";
import SearchModal from "./partials/SearchModal.vue";
import { loadStoredToken } from "./tokenStorage.js";
import LoadingIndicator from "./components/LoadingIndicator.vue";
import router from "./router.js";
const globalStore = useGlobalStore();
const isSearchModalVisible = ref(false);
const loadingIndicator = ref();
const navBar = ref();
const route = useRoute();
const toast = useToast();
// '/' to search
Mousetrap.bind("/", () => {
if (route.name !== "login") {
toggleSearchModal();
return false;
}
});
// 'CTRL + ALT/OPT + N' to create new note
Mousetrap.bindGlobal("ctrl+alt+n", () => {
if (route.name !== "login") {
router.push({ name: "new" });
return false;
}
});
// 'CTRL + ALT/OPT + H' to go to home
Mousetrap.bindGlobal("ctrl+alt+h", () => {
if (route.name !== "login") {
router.push({ name: "home" });
return false;
}
});
getConfig()
.then((data) => {
globalStore.config = data;
loadingIndicator.value.setLoaded();
})
.catch((error) => {
apiErrorHandler(error, toast);
loadingIndicator.value.setFailed();
});
loadStoredToken();
const showNavBar = computed(() => {
return route.name !== "login";
});
const showNavBarLogo = computed(() => {
return route.name !== "home";
});
function toggleSearchModal() {
isSearchModalVisible.value = !isSearchModalVisible.value;
}
loadTheme();
</script>