-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.vue
140 lines (114 loc) · 2.89 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<script setup>
import { ref, computed, onMounted, onBeforeMount } from 'vue'
import relayManager from '@/helpers/relayManager.js'
import { useSessionStore } from '@/stores/session'
import sessionRelayService from '@/helpers/sessionRelayService.js'
import themes from '@/data/themes.json'
import * as linkify from "linkifyjs"
import mitt from 'mitt'
const route = useRoute()
const sessionStore = useSessionStore()
const isMounted = ref(false)
const showTheme = ref(false)
watch(() => route.query, (newValue, oldValue) => updateFromRoute(newValue, oldValue))
watch(() => route.path, (newValue, oldValue) => updateFromRoutePath(newValue, oldValue))
const wrapStyle = computed(() => {
const result = {}
if(showTheme.value && theme.value) {
result.backgroundColor = theme.value.color
}
return result
})
const activeThemeId = computed(() => {
return sessionStore.theme || 'space'
})
const theme = computed(() => {
return themes[activeThemeId.value]
})
const classObject = computed(() => {
const c = ['site-wrap']
if(route.name.indexOf('create-') === 0) {
c.push('-create')
}
if(showTheme.value && theme.value && isMounted.value) {
c.push('-theme-'+activeThemeId.value)
c.push('-brightness-'+theme.value.brightness)
} else if(!showTheme.value) {
c.push('-brightness-light')
}
return c.join(' ')
})
relayManager.init()
function updateFromRoute() {
if(route.query.t && themes[route.query.t]) {
sessionStore.setTheme(route.query.t)
}
}
function updateFromRoutePath() {
const noThemePages = ['/', '/about']
showTheme.value = noThemePages.indexOf(route.path) === -1
}
onBeforeMount(() => {
const emitter = mitt()
window.emitter = emitter
updateFromRoute()
updateFromRoutePath()
})
onMounted(() => {
linkify.registerCustomProtocol('nostr', true)
isMounted.value = true
if(sessionStore.isLoggedIn) {
sessionRelayService.init()
}
})
updateFromRoute()
updateFromRoutePath()
</script>
<template>
<div :class="classObject" :style="wrapStyle">
<client-only>
<SiteBackground
v-if="showTheme"
:themeId="activeThemeId"
:theme="theme"
/>
<ModalSearch />
<ModalRelays />
<ModalThemes />
<ModalHandler />
<ModalZapMain />
<ModalQr />
<NotificationDrawer />
</client-only>
<Header />
<div class="site-content">
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</div>
</div>
</template>
<style scoped lang="scss">
.site-wrap {
display: flex;
flex-direction: column;
min-height: 100vh;
background-size: cover;
background-position: center center;
background-attachment: fixed;
transition: all 400ms $ease;
.site-content {
position: relative;
}
&.-create {
@include media-query(small) {
.site-content {
flex-grow: 1;
display: flex;
flex-direction: column;
padding-bottom: 15px;
}
}
}
}
</style>