App.vue 977 B

12345678910111213141516171819202122232425262728293031323334
  1. <script setup lang="ts">
  2. import type { ConfigProviderProps, ConfigProviderTheme } from 'vant'
  3. import { useDark, useToggle } from '@vueuse/core'
  4. const isDark = useDark()
  5. const toggleDark = useToggle(isDark)
  6. const theme = computed<ConfigProviderTheme>(() => isDark.value ? 'dark' : 'light')
  7. const themeVars: ConfigProviderProps['themeVars'] = {
  8. }
  9. </script>
  10. <template>
  11. <van-config-provider
  12. :theme="theme" :theme-vars="themeVars"
  13. class="w-screen h-screen bg-light-900 text-dark-900 flex flex-col " :class="isDark && 'bg-dark-900 text-light-900'"
  14. >
  15. <!-- <van-nav-bar title="标题">
  16. <template #right>
  17. <button @click="toggleDark()" class="text-18px">
  18. <i-carbon-moon v-show="isDark" class="text-light-900" />
  19. <i-carbon-sun v-show="!isDark" class="text-dark-900" />
  20. </button>
  21. </template>
  22. </van-nav-bar> -->
  23. <div class="overflow-y-auto">
  24. <router-view />
  25. </div>
  26. </van-config-provider>
  27. </template>