修复DockLayout浮动窗口按钮点击无效问题

- 修复浮动窗口和面板按钮点击时触发拖拽而非按钮功能的问题
- 在Area.vue和Panel.vue中的所有按钮添加 @mousedown.stop 阻止事件冒泡
- 修复的事件类型包括:最大化、关闭、折叠等所有按钮
- 确保按钮点击时只触发相应的功能,不影响拖拽功能

修复文件:
- AutoRobot/Windows/Robot/Web/src/DockLayout/Area.vue
- AutoRobot/Windows/Robot/Web/src/DockLayout/Panel.vue
- AutoRobot/Windows/Robot/Web/src/views/DockLayoutTest.vue
This commit is contained in:
zqm
2025-11-14 16:43:00 +08:00
parent 894fb8b87c
commit fd4c694b46
3 changed files with 50 additions and 6 deletions

View File

@@ -66,7 +66,10 @@
<span class="vs-title-text">{{ title || '面板区' }}</span>
</div>
<div class="vs-title-right title-bar-buttons flex items-center gap-0.5">
<button class="button-icon p-[2px] rounded hover:opacity-100 opacity-80" :aria-label="isMaximized ? '还原' : '最大化'" @click="onToggleMaximize">
<button class="button-icon p-[2px] rounded hover:opacity-100 opacity-80"
:aria-label="isMaximized ? '还原' : '最大化'"
@click.stop="onToggleMaximize"
@mousedown.stop>
<svg v-if="!isMaximized" class="icon-square-svg" width="11" height="11" viewBox="0 0 11 11" aria-hidden="true">
<rect x="0.5" y="0.5" width="10" height="10" fill="#cbd6ff" stroke="#8ea3d8" stroke-width="1" />
<rect x="3" y="3" width="5" height="1" fill="#b8c6ff" />
@@ -82,7 +85,10 @@
M2 6 L12.6 5 L7 6 L7 10 L2 10 Z" />
</svg>
</button>
<button class="button-icon p-[2px] rounded hover:opacity-100 opacity-80" aria-label="关闭" @click="onClose">
<button class="button-icon p-[2px] rounded hover:opacity-100 opacity-80"
aria-label="关闭"
@click.stop="onClose"
@mousedown.stop>
<svg width="11" height="11" viewBox="0 0 11 11" aria-hidden="true">
<line x1="2" y1="2" x2="9" y2="9" stroke="#e6efff" stroke-width="1"></line>
<line x1="2" y1="9" x2="9" y2="2" stroke="#e6efff" stroke-width="1"></line>
@@ -586,6 +592,8 @@ onMounted(() => {
color: #ffffff;
background: linear-gradient(to bottom, var(--vs-blue-top), var(--vs-blue-bottom));
border-bottom: 1px solid var(--vs-blue-deep);
z-index: 15; /* 确保标题栏在调整手柄之上 */
position: relative; /* 为z-index生效 */
}
.vs-title-left { display: flex; align-items: center; gap: 6px; }
.vs-app-icon { font-size: 12px; opacity: 0.9; }
@@ -594,6 +602,8 @@ onMounted(() => {
.vs-btn {
width: 22px; height: 18px; line-height: 18px;
color: #ffffff; background: transparent; border: none; padding: 0; cursor: default;
position: relative; /* 确保按钮层级生效 */
z-index: 16; /* 确保按钮在最上层 */
}
.vs-btn:hover { background: rgba(255,255,255,0.12); }
.vs-close:hover { background: #e81123; }
@@ -635,7 +645,7 @@ onMounted(() => {
/* 调整大小的手柄样式 */
.resize-handle {
position: absolute;
z-index: 20;
z-index: 14; /* 调整手柄应该在标题栏之下,但在正常区域内 */
background: transparent;
pointer-events: auto;
}