-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.vue
More file actions
86 lines (77 loc) · 3.19 KB
/
app.vue
File metadata and controls
86 lines (77 loc) · 3.19 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
<template>
<v-app>
<v-layout>
<v-app-bar density="compact">
<template v-slot:prepend>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" :color="drawer ? 'secondary' : 'primary'"></v-app-bar-nav-icon>
</template>
<v-spacer></v-spacer>
<v-text-field style="width: 100%; max-width: 400px;" placeholder="සෙවුම් පද මෙතැන යොදන්න" v-model="searchTerm"
density="compact" hide-details @update:modelValue="doSearch" @update:focused="checkSearch"></v-text-field>
<!-- <v-app-bar-title color="primary" class="app-title">අරුත.lk</v-app-bar-title> -->
<v-spacer></v-spacer>
<template v-if="display.smAndUp || drawer">
<v-divider class="mx-3 align-self-center" length="24" thickness="2" vertical></v-divider>
<v-btn icon="mdi-home" to="/"></v-btn>
<v-btn prepend-icon="mdi-new-box" to="/recent/3">අලුත් ගොනු</v-btn>
<v-btn icon="mdi-theme-light-dark" @click.stop="darkMode = !darkMode"></v-btn>
</template>
</v-app-bar>
<v-main>
<NuxtLayout>
<v-sheet class="d-flex flex-column align-center justify-center" :style="settingsStore.fontSizeStyle">
<NuxtPage />
</v-sheet>
</NuxtLayout>
</v-main>
</v-layout>
<v-snackbar app v-model="settingsStore.snackbar.model" top rounded="pill" color="info"
:timeout="settingsStore.snackbar.timeout" >
<div style="text-align: center;"><span>{{ settingsStore.snackbar.message }}</span></div>
</v-snackbar>
</v-app>
</template>
<script setup>
useHead({
titleTemplate: (titleChunk) => titleChunk ? `${titleChunk} - Tipitaka.lk` : 'Tipitaka.lk',
})
const searchTerm = ref('')
// prevent multiple searches that makes the UI sluggish when typing fast in the search box
let timeoutId
function doSearch(term) {
if (!term.trim().length) return
clearTimeout(timeoutId)
timeoutId = setTimeout(() => navigateTo('/search/' + term.trim().toLowerCase()), 400)
}
function checkSearch(focused) {
if (focused && searchTerm.value.length && !useRoute().path.includes('search')) doSearch(searchTerm.value)
}
import { useSettingsStore } from '@/stores/settings'
const settingsStore = useSettingsStore()
await settingsStore.loadConfig()
import { useTheme, useDisplay } from 'vuetify'
const theme = useTheme(), display = ref(useDisplay())
const drawer = computed({
get() { return settingsStore.settings.drawer },
set(val) { settingsStore.setSetting('drawer', val) }
})
const darkMode = computed({
get() { return settingsStore.settings.darkMode },
set(val) {
settingsStore.setSetting('darkMode', val)
theme.global.name.value = val ? 'dark' : 'light'
}
})
onMounted(() => {
settingsStore.loadSettings()
console.log(`settings darkMode = ${darkMode.value}`)
theme.global.name.value = darkMode.value ? 'dark' : 'light'
})
</script>
<style>
@font-face { src: local('###'), url('/fonts/UN-Abhaya.ttf') format('truetype'); font-weight: normal; font-family: 'sinhala'; }
@font-face { src: local('###'), url('/fonts/UN-Alakamanda-4-95.ttf') format('truetype'); font-weight: normal; font-family: 'styled'; }
body {
font-family: 'sinhala';
}
</style>