Skip to content

Commit b7825c9

Browse files
committed
feat: container use slot
1 parent 2f38055 commit b7825c9

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

src/app.scss

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,25 @@ select {
6363
@extend .form-select;
6464
@extend .select-sm;
6565
}
66-
67-
.g-active {
66+
.layer {
67+
&:hover {
68+
outline: 1px solid #ddd !important;
69+
}
70+
}
71+
.g-active {
6872
outline: 1px solid #2196f3 !important;
73+
&:hover {
74+
outline: 1px solid #2196f3 !important;
75+
}
76+
&::after {
77+
content: attr(data-title);
78+
background: #2196f3;
79+
color: #fff;
80+
position: absolute;
81+
top: 0;
82+
right: 0;
83+
padding: 0 5px;
84+
font-size: 12px;
85+
border-radius: 0 0 0 4px;
86+
}
6987
}

src/components/viewport/index.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@
1212
<component
1313
:is="val.type"
1414
class="layer"
15+
:data-title="val.type"
1516
:class="{'g-active': id === val.uuid}"
1617
v-for="val in widgetStore"
1718
:key="val.uuid"
1819
:val="val"
1920
:h="height"
2021
:w="750"
2122
:playState="playState">
23+
<component
24+
v-if="val.type === 'braid-container'"
25+
:is="child.type"
26+
class="layer layer-child"
27+
:class="{'g-active': id === child.uuid}"
28+
v-for="child in getChilds(val.name)"
29+
:key="child.uuid"
30+
:val="child"
31+
:h="height"
32+
:w="750"
33+
:playState="playState" />
2234
</component>
2335

2436
<!-- 参考线 -->
@@ -123,6 +135,13 @@ export default {
123135
this.$store.commit('replaceImage', payload)
124136
})
125137
}
138+
},
139+
140+
// 获取子组件
141+
getChilds (name) {
142+
return this.$store.state.widgets.filter(
143+
item => item.belong === name
144+
)
126145
}
127146
},
128147

src/widgets/container/index.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,8 @@
2424
}">
2525

2626
<!-- 子组件 -->
27-
<component
28-
:is="val.type"
29-
class="layer layer-child"
30-
:class="{'g-active': current === val.uuid}"
31-
v-for="val in childs"
32-
:key="val.uuid"
33-
:val="val"
34-
:h="val.height"
35-
:w="val.width"
36-
:playState="playState">
37-
</component>
27+
<!-- TODO: 改用 slot 实现 -->
28+
<slot></slot>
3829
</div>
3930
</template>
4031

0 commit comments

Comments
 (0)