index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <el-dropdown trigger="click" @command="handleSetSize">
  3. <div>
  4. <i class="el-icon-rank" />
  5. </div>
  6. <el-dropdown-menu slot="dropdown">
  7. <el-dropdown-item :disabled="size==='medium'" command="medium">Medium</el-dropdown-item>
  8. <el-dropdown-item :disabled="size==='small'" command="small">Small</el-dropdown-item>
  9. <el-dropdown-item :disabled="size==='mini'" command="mini">Mini</el-dropdown-item>
  10. </el-dropdown-menu>
  11. </el-dropdown>
  12. </template>
  13. <script>
  14. export default {
  15. computed: {
  16. size() {
  17. return this.$store.getters.size
  18. }
  19. },
  20. methods: {
  21. handleSetSize(size) {
  22. this.$ELEMENT.size = size
  23. this.$store.dispatch('setSize', size)
  24. this.refreshView()
  25. this.$message({
  26. message: '布局尺寸切换成功',
  27. type: 'success'
  28. })
  29. },
  30. refreshView() {
  31. // In order to make the cached page re-rendered
  32. this.$store.dispatch('delAllCachedViews', this.$route)
  33. const { fullPath } = this.$route
  34. this.$nextTick(() => {
  35. this.$router.replace({
  36. path: '/redirect' + fullPath
  37. })
  38. })
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. .el-icon-rank {
  45. display: inline-block;
  46. cursor: pointer;
  47. fill: #5a5e66;;
  48. width: 20px;
  49. height: 20px;
  50. font-size: 20px;
  51. }
  52. </style>