小说小程序前端代码仓库(小程序)
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.

31 lines
654 B

  1. <template>
  2. <view :class="{'dark-mode': isDarkMode}" class="theme-provider">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. import { mapGetters, mapMutations } from 'vuex'
  8. export default {
  9. name: 'ThemeProvider',
  10. computed: {
  11. ...mapGetters(['isDarkMode', 'currentTheme'])
  12. },
  13. methods: {
  14. ...mapMutations(['toggleThemeMode', 'setThemeMode'])
  15. }
  16. }
  17. </script>
  18. <style lang="scss">
  19. .theme-provider {
  20. /* 确保占满容器,但不影响布局 */
  21. width: 100%;
  22. height: 100%;
  23. /* 适配应用到深色模式的样式 */
  24. &.dark-mode {
  25. /* 这里不添加具体样式,由子元素通过对应的类应用样式 */
  26. }
  27. }
  28. </style>