Files
dm-manage-web/src/components/SizeSelect/index.vue

56 lines
1.3 KiB
Vue
Raw Normal View History

2023-02-15 09:17:05 +08:00
<template>
<el-dropdown trigger="click" @command="handleSetSize">
<div>
<svg-icon class-name="size-icon" icon-class="size" />
</div>
<el-dropdown-menu slot="dropdown">
<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>
</el-dropdown>
</template>
<script>
export default {
data() {
return {
sizeOptions: [
{ label: 'Default', value: 'default' },
{ label: 'Medium', value: 'medium' },
{ label: 'Small', value: 'small' },
{ label: 'Mini', value: 'mini' }
]
2023-03-21 00:53:28 +08:00
};
2023-02-15 09:17:05 +08:00
},
computed: {
size() {
2023-03-21 00:53:28 +08:00
return this.$store.getters.size;
2023-02-15 09:17:05 +08:00
}
},
methods: {
handleSetSize(size) {
2023-03-21 00:53:28 +08:00
this.$ELEMENT.size = size;
this.$store.dispatch('app/setSize', size);
this.refreshView();
2023-02-15 09:17:05 +08:00
this.$message({
message: 'Switch Size Success',
type: 'success'
2023-03-21 00:53:28 +08:00
});
2023-02-15 09:17:05 +08:00
},
refreshView() {
// In order to make the cached page re-rendered
2023-03-21 00:53:28 +08:00
this.$store.dispatch('tagsView/delAllCachedViews', this.$route);
2023-02-15 09:17:05 +08:00
2023-03-21 00:53:28 +08:00
const { fullPath } = this.$route;
2023-02-15 09:17:05 +08:00
this.$nextTick(() => {
this.$router.replace({
path: '/redirect' + fullPath
2023-03-21 00:53:28 +08:00
});
});
2023-02-15 09:17:05 +08:00
}
}
2023-03-21 00:53:28 +08:00
};
2023-02-15 09:17:05 +08:00
</script>