mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
优化编排卡片拖拽逻辑和效果
This commit is contained in:
parent
620f42d64b
commit
15bd91fb52
@ -3,12 +3,8 @@
|
|||||||
class="composer-card"
|
class="composer-card"
|
||||||
:class="{
|
:class="{
|
||||||
collapsed: isCollapsed && !command.isControlFlow,
|
collapsed: isCollapsed && !command.isControlFlow,
|
||||||
'drag-handle': !isLastCommandInChain,
|
|
||||||
'no-animation': isClickingControl,
|
|
||||||
}"
|
}"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@mousedown="handleMouseDown"
|
|
||||||
@mouseup="handleMouseUp"
|
|
||||||
>
|
>
|
||||||
<q-card class="command-item">
|
<q-card class="command-item">
|
||||||
<q-card-section
|
<q-card-section
|
||||||
@ -133,7 +129,6 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
showKeyRecorder: false,
|
showKeyRecorder: false,
|
||||||
isCollapsed: false,
|
isCollapsed: false,
|
||||||
isClickingControl: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -313,19 +308,6 @@ export default defineComponent({
|
|||||||
this.isCollapsed = !this.isCollapsed;
|
this.isCollapsed = !this.isCollapsed;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleMouseDown(event) {
|
|
||||||
// 检查点击的元素是否是控制元素(按钮、输入框等)
|
|
||||||
const isControlElement = event.target.closest(
|
|
||||||
".q-btn, .q-field, .q-icon, button, input, .border-label"
|
|
||||||
);
|
|
||||||
this.isClickingControl = !!isControlElement;
|
|
||||||
},
|
|
||||||
handleMouseUp() {
|
|
||||||
// 延迟重置状态,以确保动画不会立即触发
|
|
||||||
setTimeout(() => {
|
|
||||||
this.isClickingControl = false;
|
|
||||||
}, 100);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -341,42 +323,14 @@ export default defineComponent({
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.composer-card.no-animation,
|
.composer-card,
|
||||||
.composer-card.no-animation::before,
|
.composer-card::before,
|
||||||
.composer-card.no-animation .command-item {
|
.composer-card .command-item {
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
transform: none !important;
|
transform: none !important;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.composer-card.drag-handle {
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
.composer-card.no-animation.drag-handle {
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
.composer-card.drag-handle:active {
|
|
||||||
cursor: grabbing;
|
|
||||||
}
|
|
||||||
|
|
||||||
.composer-card.drag-handle:hover::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: var(--q-primary);
|
|
||||||
opacity: 0.03;
|
|
||||||
border-radius: inherit;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.composer-card.drag-handle:active::before {
|
|
||||||
opacity: 0.06;
|
|
||||||
transform: scale(0.99);
|
|
||||||
}
|
|
||||||
|
|
||||||
.command-item {
|
.command-item {
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
@ -387,32 +341,11 @@ export default defineComponent({
|
|||||||
will-change: transform;
|
will-change: transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drag-handle .command-item {
|
|
||||||
transition: transform 0.2s ease, box-shadow 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drag-handle:hover .command-item {
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.drag-handle:active .command-item {
|
|
||||||
transform: translateY(0) scale(0.98);
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 暗色模式适配 */
|
/* 暗色模式适配 */
|
||||||
.body--dark .command-item {
|
.body--dark .command-item {
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.body--dark .drag-handle:hover .command-item {
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.body--dark .drag-handle:active .command-item {
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.body--dark .composer-card.drag-handle:hover::before {
|
.body--dark .composer-card.drag-handle:hover::before {
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
@ -642,4 +642,11 @@ export default defineComponent({
|
|||||||
.flow-item.insert-before + .flow-item {
|
.flow-item.insert-before + .flow-item {
|
||||||
transform: translateY(3px);
|
transform: translateY(3px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flow-item.sortable-ghost {
|
||||||
|
opacity: 0.5;
|
||||||
|
transform: scale(0.99);
|
||||||
|
border: 1px solid var(--q-primary);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<div v-if="!isControlFlow" class="text-subtitle2 command-label">
|
<div class="text-subtitle2 command-label q-px-sm drag-handle">
|
||||||
{{ command.label }}
|
{{ command.label }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -99,14 +99,9 @@ export default {
|
|||||||
.chain-icon {
|
.chain-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-right: 4px;
|
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chain-icon {
|
|
||||||
margin-right: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapse-btn :deep(.q-btn),
|
.collapse-btn :deep(.q-btn),
|
||||||
.chain-icon {
|
.chain-icon {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
@ -122,6 +117,13 @@ export default {
|
|||||||
|
|
||||||
.command-label {
|
.command-label {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
pointer-events: none;
|
pointer-events: all;
|
||||||
|
cursor: grab;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.command-label:hover {
|
||||||
|
color: var(--q-primary);
|
||||||
|
transition: all 0.3s ease;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
<div class="row items-end no-wrap">
|
<div class="row items-end no-wrap">
|
||||||
<!-- 类型标签 -->
|
<!-- 类型标签 -->
|
||||||
<div class="control-type-label">
|
<div class="control-type-label">
|
||||||
<template v-if="type === 'if'">如果满足</template>
|
<template v-if="type === 'if'">如果</template>
|
||||||
<template v-else-if="type === 'else'">
|
<template v-else-if="type === 'else'"> 否则 </template>
|
||||||
{{ showCondition ? "否则满足" : "否则" }}
|
<template v-else>结束</template>
|
||||||
</template>
|
|
||||||
<template v-else>结束条件判断</template>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- if类型显示添加按钮 -->
|
<!-- if类型显示添加按钮 -->
|
||||||
@ -159,7 +157,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.control-type-label {
|
.control-type-label {
|
||||||
font-size: 14px;
|
font-size: 13px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
<div class="loop-control row">
|
<div class="loop-control row">
|
||||||
<!-- 类型标签和按钮区域 -->
|
<!-- 类型标签和按钮区域 -->
|
||||||
<div class="control-type-label">
|
<div class="control-type-label">
|
||||||
<template v-if="type === 'loop'">循环</template>
|
<template v-if="type === 'loop'">开始</template>
|
||||||
<template v-else-if="type === 'continue'">继续循环</template>
|
<template v-else-if="type === 'continue'">继续</template>
|
||||||
<template v-else-if="type === 'break'">终止循环</template>
|
<template v-else-if="type === 'break'">终止</template>
|
||||||
<template v-else>结束循环</template>
|
<template v-else>结束</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 只在循环开始时显示添加按钮 -->
|
<!-- 只在循环开始时显示添加按钮 -->
|
||||||
@ -193,7 +193,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.control-type-label {
|
.control-type-label {
|
||||||
font-size: 14px;
|
font-size: 13px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user