index.vue 600 B

12345678910111213141516171819202122
  1. <template>
  2. <n-button quaternary @click="changeTheme" title="主题">
  3. <n-icon size="20" :depth="1">
  4. <moon-icon v-if="designStore.darkTheme"></moon-icon>
  5. <sunny-icon v-else></sunny-icon>
  6. </n-icon>
  7. </n-button>
  8. </template>
  9. <script lang="ts" setup>
  10. import { useDesignStore } from '@/store/modules/designStore/designStore'
  11. import { setHtmlTheme } from '@/utils'
  12. import { icon } from '@/plugins'
  13. const { MoonIcon, SunnyIcon } = icon.ionicons5
  14. const designStore = useDesignStore()
  15. // 改变样式
  16. const changeTheme = () => {
  17. designStore.changeTheme()
  18. setHtmlTheme()
  19. }
  20. </script>