longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
<template>
  <flex-layout class="pifu-list-wrapper" no-bg>
    <div class="pifu-list-header" slot="header">主题设置</div>
    <div class="pifu-list-content">
      <div class="pifu-list-container">
        <el-row>
          <el-col :span="12" v-for="(item, index) in skinList" :key="index">
            <div class="pifu-item">
              <div
                class="pifu-item-img"
                :class="{
                  'full-screen': fullScreen,
                  active: index == selectActive,
                }"
                @click.stop="changeSkin(item, index)"
              >
                <el-image :src="item.img">
                  <div slot="placeholder" class="image-slot">
                    <i class="el-icon-picture-outline"></i>
                  </div>
                </el-image>
              </div>
              <div class="pifu-item-txt">{{ item.name }}</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </flex-layout>
</template>
 
<script>
export default {
  name: "PifuList",
  data() {
    return {
      fullScreen: false,
      selectActive: 0,
      skinList: [
        {
          img: require("@/assets/images/theme/science.png"),
          name: "科技蓝",
          skin: "science-blue",
        },
        {
          img: require("@/assets/images/theme/science2.png"),
          name: "荧光绿",
          skin: "science-green",
        },
        {
          img: require("@/assets/images/theme/science3.jpg"),
          name: "优雅黑",
          skin: "science-black",
        },
        {
          img: require("@/assets/images/theme/science4.png"),
          name: "木槿紫",
          skin: "science-purple",
        },
        {
          img: require("@/assets/images/theme/science5.png"),
          name: "紫罗兰",
          skin: "science-ziluolan",
        },
        {
          img: require("@/assets/images/theme/science6.png"),
          name: "靛青色",
          skin: "science-skyBlue",
        },
      ],
    };
  },
  mounted() {
    this.skinList.forEach((item, index) => {
      if (item.skin == this.$store.state.theme.activeSkin) {
        this.selectActive = index;
      }
    });
  },
  methods: {
    prePifu() {
      this.fullScreen = this.fullScreen ? false : true;
    },
    changeSkin(item, index) {
      let skin = item.skin;
      let name = item.name;
      this.$store.commit("theme/changeTheme", skin);
      this.$store.dispatch("theme/changeThemeName", name);
      this.$addSkinStorageEvent("activeSkin", skin);
      this.selectActive = index;
    },
  },
};
</script>
 
<style scoped>
.pifu-list {
  display: flex;
  height: 100%;
}
 
.pifu-list-header {
  margin-top: 4px;
  margin-left: 4px;
  margin-right: 4px;
  padding-left: 10px;
  border-radius: 4px;
  font-size: 20px;
  text-align: center;
  line-height: 36px;
  font-weight: bold;
}
 
.pifu-item {
  padding: 8px;
}
 
.pifu-list-container {
  margin-top: 4px;
  margin-left: 4px;
  margin-right: 4px;
}
 
.pifu-item-img.full-screen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
 
.pifu-item-img {
  width: 100%;
  height: 100px;
}
 
.pifu-item-img img {
  width: 100%;
  height: 100%;
}
 
.pifu-item-txt {
  user-select: none;
  text-align: center;
}
 
.pre-pifu {
  margin-left: 8px;
  font-size: 14px;
  color: #4279dc;
  cursor: pointer;
}
 
.pre-pifu:hover {
  color: #6e9bea;
}
 
.pre-pifu:active {
  color: #ff0000;
}
</style>