empty.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <Nuxt />
  3. </template>
  4. <script lang="ts">
  5. import { onBeforeMount, watch, defineComponent } from "@nuxtjs/composition-api"
  6. import { useColorMode } from "~/helpers/utils/composables"
  7. import { setupLocalPersistence } from "~/newstore/localpersistence"
  8. import { useSetting } from "~/newstore/settings"
  9. function updateThemes() {
  10. const $colorMode = useColorMode()
  11. // Apply theme updates
  12. const themeColor = useSetting("THEME_COLOR")
  13. const bgColor = useSetting("BG_COLOR")
  14. const fontSize = useSetting("FONT_SIZE")
  15. // Initially apply
  16. onBeforeMount(() => {
  17. document.documentElement.setAttribute("data-accent", themeColor.value)
  18. $colorMode.preference = bgColor.value
  19. document.documentElement.setAttribute("data-font-size", fontSize.value)
  20. })
  21. // Listen for updates
  22. watch(themeColor, () =>
  23. document.documentElement.setAttribute("data-accent", themeColor.value)
  24. )
  25. watch(bgColor, () => ($colorMode.preference = bgColor.value))
  26. watch(fontSize, () =>
  27. document.documentElement.setAttribute("data-font-size", fontSize.value)
  28. )
  29. }
  30. export default defineComponent({
  31. setup() {
  32. updateThemes()
  33. },
  34. beforeMount() {
  35. setupLocalPersistence()
  36. },
  37. })
  38. </script>