重构 DropArea 组件:用条件渲染替换 EmptyFlow,增强拖放视觉效果,并移除未使用的 EmptyFlow.vue 文件

This commit is contained in:
fofolee
2025-01-22 08:39:15 +08:00
parent d69c473fe7
commit 31e9ca6956
3 changed files with 88 additions and 59 deletions

View File

@@ -1,6 +1,24 @@
<template>
<div class="drop-area">
<q-icon name="add" size="32px" />
<div
class="drop-area"
@dragenter="isDragging = true"
@dragleave="isDragging = false"
@drop="isDragging = false"
:class="{
'drop-area-dragging': isDragging,
}"
>
<template v-if="type === 'add'">
<div class="add-area">
<q-icon name="add" size="32px" />
</div>
</template>
<template v-else-if="type === 'empty'">
<div class="empty-area">
<q-icon name="drag_indicator" size="32px" />
<div class="text-body2">从左侧拖拽命令到这里开始编排</div>
</div>
</template>
</div>
</template>
@@ -8,25 +26,82 @@
import { defineComponent } from "vue";
export default defineComponent({
name: "DropArea",
name: "EmptyFlow",
props: {
type: {
type: String,
default: "add",
},
},
data() {
return {
isDragging: false,
};
},
});
</script>
<style scoped>
.drop-area {
flex: 1;
min-height: 50px;
border-radius: 8px;
margin: 8px;
display: flex;
align-items: center;
justify-content: center;
color: #9994;
border: 2px dashed #9994;
border: 2px dashed #e0e0e0;
border-radius: 4px;
margin: 8px 0;
transition: all 0.3s ease;
flex: 1;
user-select: none;
transition: all 0.3s ease;
}
.body--dark .drop-area {
color: #6664;
border: 2px dashed #6664;
border-color: #676666;
}
.drop-area:hover,
.drop-area-dragging {
border-color: #bdbdbd;
background-color: #f9f9f9;
}
.body--dark .drop-area:hover,
.body--dark .drop-area-dragging {
border: 2px dashed #676666;
background-color: #303132;
}
.drop-area-dragging {
position: relative;
animation: shake 0.5s ease-in-out infinite;
}
@keyframes shake {
0%,
100% {
transform: rotate(0deg);
}
25% {
transform: rotate(-0.1deg);
}
75% {
transform: rotate(0.1deg);
}
}
.add-area,
.empty-area {
display: flex;
align-items: center;
justify-content: center;
color: grey
}
.add-area {
height: 30px;
}
.empty-area {
height: 200px;
}
</style>