default.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <v-app>
  3. <v-navigation-drawer v-model="drawer" app>
  4. <v-list>
  5. <v-list-item
  6. v-for="(item, i) in items"
  7. :key="i"
  8. :to="item.to"
  9. router
  10. exact
  11. >
  12. <v-list-item-title>
  13. {{ item.title }}
  14. </v-list-item-title>
  15. </v-list-item>
  16. </v-list>
  17. </v-navigation-drawer>
  18. <v-app-bar app>
  19. <v-app-bar-nav-icon @click.stop="drawer = !drawer" />
  20. <v-toolbar-title>
  21. {{ title }}
  22. </v-toolbar-title>
  23. <v-spacer />
  24. <v-btn :icon="true" @click="toggleTheme">
  25. <v-icon>{{ isDark ? 'mdi-weather-sunny' : 'mdi-weather-night' }}</v-icon>
  26. </v-btn>
  27. </v-app-bar>
  28. <v-main>
  29. <v-container>
  30. <slot />
  31. </v-container>
  32. </v-main>
  33. </v-app>
  34. </template>
  35. <script setup lang="ts">
  36. import { ref, computed } from 'vue'
  37. import { useTheme } from 'vuetify'
  38. const theme = useTheme()
  39. const drawer = ref(false)
  40. const isDark = computed(() => theme.global.current.value.dark)
  41. const title = ref('SNC Demo')
  42. const items = [
  43. {
  44. title: 'Authors',
  45. to: '/'
  46. },
  47. {
  48. title: 'Songs',
  49. to: '/songs'
  50. },
  51. {
  52. title: 'About',
  53. to: '/about'
  54. }
  55. ]
  56. const toggleTheme = () => {
  57. theme.global.name.value = isDark.value ? 'light' : 'dark'
  58. }
  59. </script>