index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <el-dropdown trigger="click" @command="handleSetSize">
  3. <div>
  4. <svg-icon class-name="size-icon" icon-class="size" />
  5. </div>
  6. <el-dropdown-menu slot="dropdown">
  7. <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value">
  8. {{ item.label }}
  9. </el-dropdown-item>
  10. </el-dropdown-menu>
  11. </el-dropdown>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. sizeOptions: [
  18. { label: 'Default', value: 'default' },
  19. { label: 'Medium', value: 'medium' },
  20. { label: 'Small', value: 'small' },
  21. { label: 'Mini', value: 'mini' }
  22. ]
  23. }
  24. },
  25. computed: {
  26. size() {
  27. return this.$store.getters.size
  28. }
  29. },
  30. methods: {
  31. handleSetSize(size) {
  32. this.$ELEMENT.size = size
  33. this.$store.dispatch('app/setSize', size)
  34. this.refreshView()
  35. this.$message({
  36. message: 'Switch Size Success',
  37. type: 'success'
  38. })
  39. },
  40. refreshView() {
  41. // In order to make the cached page re-rendered
  42. this.$store.dispatch('tagsView/delAllCachedViews', this.$route)
  43. const { fullPath } = this.$route
  44. this.$nextTick(() => {
  45. this.$router.replace({
  46. path: '/redirect' + fullPath
  47. })
  48. })
  49. }
  50. }
  51. }
  52. </script>