小小儁爺
2024-11-04 7f188174831ebc9f60bf76e2a8b08b75d48317a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<template>
  <div class="drawer-container">
    <div>
      <h3 class="drawer-title">系统配置</h3>
 
      <div class="drawer-item">
        <span>主题颜色</span>
        <theme-picker style="float: right;height: 26px;margin: -3px 8px 0 0;" @change="themeChange" />
      </div>
 
      <div class="drawer-item" style="display: flex;justify-content: space-between">
        <span>头部颜色</span>
        <el-switch
          v-model="$store.state.settings.headBackgroundColorValue"
          style="display: block"
          active-color="#304156"
          inactive-color="#ccc"
          active-text="深色"
          inactive-text="浅色"
        />
      </div>
      <div class="drawer-item" style="display: flex;justify-content: space-between">
        <span>菜单模式</span>
        <el-switch
          v-model="$store.state.settings.menuIsHorizontal"
          style="display: block"
          :active-color="$store.state.settings.theme"
          inactive-color="#ccc"
          active-text="横向"
          inactive-text="竖向"
          @change="sidebar.opened=true"
        />
      </div>
      <div class="drawer-item" style="display: flex;justify-content: space-between">
        <span>左侧颜色</span>
        <el-switch
          v-model="$store.state.settings.leftBackgroundColorValue"
          style="display: block"
          active-color="#304156"
          :disabled="$store.state.settings.menuIsHorizontal"
          inactive-color="#ccc"
          active-text="深色"
          inactive-text="浅色"
        />
      </div>
      <div class="drawer-item" style="display: flex;justify-content: space-between">
        <span>动画类型</span>
        <el-select
          v-model="$store.state.settings.animationType"
          :popper-append-to-body="false"
          popper-class="animationTypePopperClass"
          style="width: 120px;"
          placeholder="请选择"
          size="mini"
        >
          <el-option
            v-for="item in animationTypeArr"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
 
      <!--      此三个功能暂时不用-->
      <!--      <div class="drawer-item">-->
      <!--        <span>Open Tags-View</span>-->
      <!--        <el-switch v-model="tagsView" class="drawer-switch" />-->
      <!--      </div>-->
 
      <!--      <div class="drawer-item">-->
      <!--        <span>Fixed Header</span>-->
      <!--        <el-switch v-model="fixedHeader" class="drawer-switch" />-->
      <!--      </div>-->
 
      <!--      <div class="drawer-item">-->
      <!--        <span>Sidebar Logo</span>-->
      <!--        <el-switch v-model="sidebarLogo" class="drawer-switch" />-->
      <!--      </div>-->
 
    </div>
  </div>
</template>
 
<script>
import ThemePicker from '@/components/ThemePicker'
import { mapGetters } from 'vuex'
 
export default {
  components: { ThemePicker },
  data() {
    return {
      animationTypeArr: [
        { label: '默认类型', value: 'fade-transform' },
        { label: '淡入', value: 'el-fade-in-linear' },
        { label: '淡出', value: 'el-fade-in' },
        { label: '中间缩放', value: 'el-zoom-in-center' },
        { label: '顶部缩放', value: 'el-zoom-in-top' },
        { label: '底部缩放', value: 'el-zoom-in-bottom' },
        { label: '展开折叠', value: 'el-collapse-transition' },
        { label: '无动画', value: 'none' }
      ]
    }
  },
  mounted() {
    if (this.$store.state.settings.menuIsHorizontal) {
      this.sidebar.opened = true
    }
  },
  computed: {
    ...mapGetters([
      'sidebar'
    ]),
    fixedHeader: {
      get() {
        return this.$store.state.settings.fixedHeader
      },
      set(val) {
        this.$store.dispatch('settings/changeSetting', {
          key: 'fixedHeader',
          value: val
        })
      }
    },
    tagsView: {
      get() {
        return this.$store.state.settings.tagsView
      },
      set(val) {
        this.$store.dispatch('settings/changeSetting', {
          key: 'tagsView',
          value: val
        })
      }
    },
    sidebarLogo: {
      get() {
        return this.$store.state.settings.sidebarLogo
      },
      set(val) {
        this.$store.dispatch('settings/changeSetting', {
          key: 'sidebarLogo',
          value: val
        })
      }
    }
  },
 
  methods: {
    themeChange(val) {
      this.$store.dispatch('settings/changeSetting', {
        key: 'theme',
        value: val
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep .animationTypePopperClass {
  left: auto !important;
}
 
.drawer-container {
  padding: 24px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
 
  .drawer-title {
    margin-bottom: 12px;
    color: rgba(0, 0, 0, .85);
    font-size: 18px;
    line-height: 22px;
  }
 
  .drawer-item {
    color: rgba(0, 0, 0, .65);
    font-size: 14px;
    padding: 12px 0;
  }
 
  .drawer-switch {
    float: right
  }
}
</style>