forked from wanglin2/code-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingLayout.vue
100 lines (86 loc) · 1.82 KB
/
SettingLayout.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
<div>
<div class="settingRow">
<div class="content">
<span class="name">布局</span>
<div class="control">
<el-select v-model="layout">
<el-option
v-for="item in layoutList"
:key="item.value"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</div>
<el-button type="primary" class="btn" @click="confirm">确定</el-button>
</div>
</div>
<div class="previewImg" v-if="previewImg">
<img :src="previewImg" alt="" />
</div>
</div>
</template>
<script setup>
import { computed, ref } from "vue";
import { useStore } from "vuex";
import { layoutList, previewImgMap } from "@/config/constants";
import { ElSelect, ElButton, ElOption } from "element-plus";
// 初始化
const useInit = () => {
const store = useStore();
return {
store,
};
};
// 布局处理
const useLayout = ({ store }) => {
// 预览图片
const previewImg = computed(() => {
return previewImgMap[layout.value];
});
// 布局
const layout = ref("");
layout.value = store.state.editData.config.layout;
// 切换布局
const confirm = () => {
store.commit("setLayout", layout.value);
};
return {
previewImg,
layout,
confirm,
};
};
// created部分
const { store } = useInit();
const { previewImg, layout, confirm } = useLayout({ store });
</script>
<style scoped lang="less">
.settingRow {
margin-bottom: 20px;
.content {
display: flex;
align-items: center;
.name {
margin-right: 10px;
}
.btn {
margin-left: 10px;
}
}
.desc {
font-size: 12px;
color: #999;
}
}
.previewImg {
width: 400px;
border: 1px solid #dcdfe6;
padding: 5px;
img {
width: 100%;
}
}
</style>