default.vue 1.4 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-btn :icon="true" href="https://github.com/olinox14/snc-demo" target="_blank">
  28. <v-icon>mdi-github</v-icon>
  29. </v-btn>
  30. </v-app-bar>
  31. <v-main>
  32. <v-container>
  33. <slot />
  34. </v-container>
  35. </v-main>
  36. </v-app>
  37. </template>
  38. <script setup lang="ts">
  39. import { ref, computed } from 'vue'
  40. import { useTheme } from 'vuetify'
  41. const theme = useTheme()
  42. const drawer = ref(false)
  43. const isDark = computed(() => theme.global.current.value.dark)
  44. const title = ref('SNC Demo')
  45. const items = [
  46. {
  47. title: 'Authors',
  48. to: '/'
  49. },
  50. {
  51. title: 'About',
  52. to: '/about'
  53. }
  54. ]
  55. const toggleTheme = () => {
  56. theme.global.name.value = isDark.value ? 'light' : 'dark'
  57. }
  58. </script>