App.vue 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <router-view />
  3. </template>
  4. <script setup>
  5. import { useQuasar } from "quasar";
  6. import { StatusBar, Style } from "@capacitor/status-bar";
  7. import { Capacitor } from "@capacitor/core";
  8. import { watch, onBeforeMount } from "vue";
  9. import { useI18n } from "vue-i18n";
  10. import { Preferences } from "@capacitor/preferences";
  11. defineOptions({
  12. name: "App",
  13. });
  14. const { locale } = useI18n();
  15. const $q = useQuasar();
  16. const updateStatusBar = async () => {
  17. if (!Capacitor.isNativePlatform()) return;
  18. await StatusBar.show();
  19. await StatusBar.setStyle({
  20. style: Style.Light,
  21. });
  22. };
  23. watch(
  24. () => locale.value,
  25. async (value) => {
  26. await Preferences.set({ key: "locale", value });
  27. },
  28. );
  29. onBeforeMount(async () => {
  30. $q.dark.set(false);
  31. await updateStatusBar();
  32. const { value: localePref } = await Preferences.get({ key: "locale" });
  33. const userLocale = localePref || window.navigator.language;
  34. console.log(userLocale);
  35. });
  36. </script>