-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.vue
109 lines (95 loc) · 3.34 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
<template>
<div v-if="loaded" id="ragab-app">
<!-- 🚧 - App Layouts -->
<!-- For Debugging the player -->
<div v-if="false" class="fixed bottom-0 right-0 p-5">
<UCard>
app.vue
<div>
<pre>
<code>{{ player?.url }}</code>
<code>
{{ mediaProgressInSeconds }}
{{ mediaProgressInMinutes }}
{{mediaProgressPercentage}}
{{ mediaProgressFormatted }}
</code>
</pre>
</div>
<template #footer>
<div v-if="player">
<UButton @click="player.toggle()"> toggle </UButton>
</div>
</template>
</UCard>
</div>
<NuxtLayout></NuxtLayout>
<!-- Footer -->
<div dir="ltr" class="flex items-center justify-center px-4 py-10">
by
<a href="https://github.com/ahmedragab20" target="_blank" class="mx-1 text-primary-500">
Ragab
</a>
<small class="text-gray-400 dark:text-gray-500">© 2023</small>
</div>
<!-- 🤷🏻♂️ - so global -->
<!-- Toasts -->
<UNotifications />
<!-- Modals -->
<UModal v-model="authStore.authLanded">
<AuthLand :target="chosenAuthLand" />
</UModal>
</div>
<div v-else class="flex flex-col items-center justify-center h-screen gap-4">
<div v-for="n in 4" :key="n">
<div class="flex items-center space-x-4">
<USkeleton class="w-12 h-12 rounded-full" />
<div class="space-y-2">
<USkeleton class="h-4 w-[250px]" />
<USkeleton class="h-4 w-[200px]" />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useAudioPlayerStore } from '~/stores/audio-player';
import { useAuthStore } from '~/stores/auth';
type AuthLand = 'login' | 'register' | 'forgot' | 'reset' | 'verify'; //TODO:: search why it fails to be imported if you added it in types/index.ts
const authStore = useAuthStore();
const audioPlayerStore = useAudioPlayerStore();
const { locale } = useI18n();
const appConfig = useAppConfig();
const appSettings = ref();
const loaded = ref(false);
const chosenAuthLand = computed<AuthLand>(() => authStore.chosenAuthLand); // fallback to login
const initTheme = () => {
if (process.client) {
appSettings.value = localStorage.getItem('appSettings');
if (!!appSettings.value) {
const settings = JSON.parse(appSettings.value);
appConfig.ui.primary = settings.color?.primary || 'green';
appConfig.ui.gray = settings.color?.secondary || 'cool';
locale.value = settings.language || 'en';
locale.value?.includes('ar') ? (document.dir = 'rtl') : (document.dir = 'ltr');
}
}
};
const toggleAudio = () => {
const audio = audioPlayerStore.audio;
audio.toggle();
console.log('audio', audio);
};
const player = useState('audio', () => null);
const mediaProgressPercentage = useState<any>('mediaProgressPercentage', () => 0);
const mediaProgressInSeconds = useState<any>('mediaProgressInSeconds', () => 0);
const mediaProgressInMinutes = useState<any>('mediaProgressInMinutes', () => 0);
const mediaProgressFormatted = useState<any>('mediaProgressFormatted', () => '00:00/00:00');
onMounted(() => {
initTheme();
loaded.value = true;
});
useHead({
title: 'Muslim - مُسْلِم',
});
</script>