app.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <script setup lang="ts">
  2. import { setToastDefaultOptions } from 'vant'
  3. import { useI18n } from 'vue-i18n'
  4. import { APP_LOCALE_KEY } from '~/constants'
  5. import { getDeviceLanguage } from '~/utils/helpers'
  6. useHead({
  7. titleTemplate: (titleChunk) => {
  8. return titleChunk ? `${titleChunk} - Gami` : 'Gami'
  9. },
  10. meta: [
  11. {
  12. name: 'viewport',
  13. content:
  14. 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover',
  15. },
  16. ],
  17. })
  18. useSeoMeta({
  19. ogTitle: 'Gami',
  20. ogDescription: 'Gami - Temukan teman bermainmu',
  21. ogImage: 'https://public.gami.vip/og.png',
  22. })
  23. const { setLocale } = useI18n()
  24. setToastDefaultOptions({ wordBreak: 'normal', position: 'bottom' })
  25. onMounted(() => {
  26. if (typeof window === 'undefined')
  27. return
  28. const savedLocale = window.localStorage.getItem(APP_LOCALE_KEY)
  29. if (savedLocale) {
  30. setLocale(savedLocale as 'en' | 'id' | 'zh')
  31. }
  32. else {
  33. const deviceLanguage = getDeviceLanguage()
  34. setLocale(deviceLanguage)
  35. window.localStorage.setItem(APP_LOCALE_KEY, deviceLanguage)
  36. }
  37. })
  38. </script>
  39. <template>
  40. <NuxtLayout>
  41. <NuxtPage :keepalive="{ include: ['HomePage', 'SearchPage'] }" />
  42. </NuxtLayout>
  43. </template>