ny
23 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script setup lang="ts">
import type { ThemeBgType } from '@vben/types';
 
import { Check } from '@vben/icons';
import { $t } from '@vben/locales';
 
import { blueBg, defaultBg, greenBg, purpleBg } from './bgImg';
 
defineOptions({
  name: 'PreferenceBgTheme',
});
 
const modelValue = defineModel<ThemeBgType>({ default: '' });
 
const sysBgList: any[] = [
  {
    title: $t('preferences.theme.bgType.defaultBg'),
    type: '',
    img: defaultBg,
  },
  {
    title: $t('preferences.theme.bgType.blueBg'),
    type: 'blue',
    img: blueBg,
  },
  {
    title: $t('preferences.theme.bgType.purpleBg'),
    type: 'purple',
    img: purpleBg,
  },
  {
    title: $t('preferences.theme.bgType.greenBg'),
    type: 'green',
    img: greenBg,
  },
];
 
function handleSelect(type: ThemeBgType) {
  modelValue.value = type;
}
</script>
 
<template>
  <div class="bg-type-list">
    <template v-for="item in sysBgList" :key="item.type">
      <div
        class="bg-type-item"
        :class="{
          'bg-type-item-active': item.type === modelValue,
        }"
        @click="handleSelect(item.type)"
      >
        <div class="bg-type-item-img">
          <img :src="item.img" />
          <Check class="bg-type-item-checked" v-if="item.type === modelValue" />
        </div>
        <p class="bg-type-item-title">{{ item.title }}</p>
      </div>
    </template>
  </div>
</template>
 
<style lang="scss" scoped>
.bg-type-list {
  display: flex;
  justify-content: space-between;
 
  .bg-type-item {
    width: 77px;
    cursor: pointer;
 
    &.bg-type-item-active {
      .bg-type-item-img {
        border-color: var(--primary-color);
      }
    }
 
    .bg-type-item-img {
      position: relative;
      width: 100%;
      border: 1px solid #e5ebf5;
      border-radius: 9px;
      box-shadow: 0 5px 5px rgb(0 0 0 / 16%);
    }
 
    .bg-type-item-title {
      margin-top: 10px;
      font-size: 12px;
      text-align: center;
    }
 
    .bg-type-item-checked {
      position: absolute;
      right: -9px;
      bottom: -1px;
      width: 20px;
      height: 20px;
      line-height: 20px;
      color: #fff;
      text-align: center;
      background: var(--primary-color);
      border-radius: 50%;
    }
  }
}
</style>