index.vue 1.4 KB

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