小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
554 B

  1. import { mapGetters, mapMutations } from 'vuex'
  2. /**
  3. * 主题模式混合器
  4. * 提供了isDarkMode和currentTheme计算属性以及toggleThemeMode和setThemeMode方法
  5. * 使用方法
  6. * 1. 在组件中导入import themeMixin from '@/mixins/themeMode.js'
  7. * 2. 在组件中注册mixins: [themeMixin]
  8. * 3. 然后可以使用this.isDarkMode this.toggleThemeMode()
  9. */
  10. export default {
  11. computed: {
  12. ...mapGetters(['isDarkMode', 'currentTheme'])
  13. },
  14. methods: {
  15. ...mapMutations(['toggleThemeMode', 'setThemeMode'])
  16. }
  17. }