index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div>
  3. <el-dropdown trigger="click" @command="handleSetSize">
  4. <div class="size-icon--style">
  5. <svg-icon class-name="size-icon" icon-class="size" />
  6. </div>
  7. <template #dropdown>
  8. <el-dropdown-menu>
  9. <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size === item.value" :command="item.value">
  10. {{ item.label }}
  11. </el-dropdown-item>
  12. </el-dropdown-menu>
  13. </template>
  14. </el-dropdown>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ElMessage } from 'element-plus'
  19. const store = useStore();
  20. const size = computed(() => store.getters.size);
  21. const route = useRoute();
  22. const router = useRouter();
  23. const {proxy} = getCurrentInstance();
  24. const sizeOptions = ref([
  25. { label: '较大', value: 'large' },
  26. { label: '默认', value: 'default' },
  27. { label: '稍小', value: 'small' },
  28. ])
  29. function refreshView() {
  30. // In order to make the cached page re-rendered
  31. store.dispatch('tagsView/delAllCachedViews', route)
  32. const { fullPath } = route
  33. nextTick(() => {
  34. router.replace({
  35. path: '/redirect' + fullPath
  36. })
  37. })
  38. }
  39. function handleSetSize(size) {
  40. proxy.$modal.loading("正在设置布局大小,请稍候...");
  41. store.dispatch('app/setSize', size)
  42. setTimeout("window.location.reload()", 1000)
  43. };
  44. </script>
  45. <style lang='scss' scoped>
  46. .size-icon--style {
  47. font-size: 18px;
  48. line-height: 50px;
  49. padding-right: 7px;
  50. }
  51. </style>