he wei
2025-04-03 c6a2d2debf161b987ff91c6ac9560d10fc98c54b
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
<template>
  <el-dropdown trigger="click" @command="handleSetSize">
    <div>
      <svg-icon class-name="size-icon" icon-class="size" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size === item.value"
          :command="item.value">
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
 
<script>
import { defineComponent } from 'vue';
import store from '@/store';
 
export default defineComponent({
  data() {
    return {
      sizeOptions: [
        { label: '默认', value: 'default' },
        { label: '大号', value: 'large' },
        { label: '小号', value: 'small' }
      ]
    };
  },
  computed: {
    size() {
      return store.app().size;
    }
  },
  methods: {
    handleSetSize(size) {
      store.app().setSize(size);
      this.refreshView();
      ElMessage({
        message: 'Switch Size Success',
        type: 'success'
      });
    },
    refreshView() {
      // In order to make the cached page re-rendered
      store.tagsView().delAllCachedViews();
 
      const { fullPath } = this.$route;
 
      this.$nextTick(() => {
        this.$router.replace({
          path: '/redirect' + fullPath
        });
      });
    }
  }
 
});
</script>