index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div
  3. class="bs-design-wrap theme-switcher-wrap"
  4. :class="`bs-theme-switcher-${customTheme}`"
  5. >
  6. <div class="label-box">
  7. 切换主题
  8. </div>
  9. <el-radio-group
  10. v-model="pageInfo.pageConfig.customTheme"
  11. size="medium "
  12. class="theme-radio"
  13. @change="handleChange"
  14. >
  15. <el-radio
  16. border
  17. label="light"
  18. >
  19. 明亮
  20. </el-radio>
  21. <el-radio
  22. border
  23. label="dark"
  24. >
  25. 暗黑
  26. </el-radio>
  27. </el-radio-group>
  28. </div>
  29. </template>
  30. <script>
  31. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  32. import { themeToSetting } from 'data-room-ui/js/utils/themeFormatting'
  33. import { mapMutations, mapState } from 'vuex'
  34. export default {
  35. name: 'ThemeSwitcher',
  36. components: {},
  37. mixins: [paramsMixins],
  38. props: {
  39. // 卡片的属性
  40. config: {
  41. type: Object,
  42. default: () => ({})
  43. }
  44. },
  45. computed: {
  46. ...mapState({
  47. pageInfo: (state) => state.bigScreen.pageInfo
  48. })
  49. },
  50. data () {
  51. return {
  52. }
  53. },
  54. watch: {
  55. },
  56. mounted () {
  57. },
  58. methods: {
  59. ...mapMutations({
  60. changePageInfo: 'bigScreen/changePageInfo'
  61. }),
  62. // 由于静态组件没有混入公共函数,所以需要定义一个changeStyle方法,以免报错
  63. changeStyle (config) {
  64. },
  65. handleChange (val) {
  66. const pageInfo = this.pageInfo
  67. pageInfo.chartList = themeToSetting(pageInfo.chartList, val)
  68. this.changePageInfo(pageInfo)
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .bs-design-wrap{
  75. width: 100%;;
  76. display: flex;
  77. align-items: center;
  78. flex-wrap: nowrap;
  79. color: #fff;
  80. .label-box{
  81. padding: 10px;
  82. margin-right: 10px;
  83. font-size: 14px;
  84. }
  85. .el-radio.is-checked {
  86. color: #00a0e9; /* 修改激活状态下的字体颜色 */
  87. }
  88. /* 修改未激活状态下的字体颜色 */
  89. .el-radio:not(.is-checked) {
  90. color: #fff; /* 修改未激活状态下的字体颜色 */
  91. }
  92. }
  93. </style>