mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-06 05:05:35 +00:00
feat: 标签页拖拽合并时支持插入到鼠标所在位置
- getAllWebTabWindowsInfo 增加返回 tabCount 用于计算标签位置 - attachToWindow 根据鼠标 screenX 和目标窗口标签信息计算插入位置 - 拖拽标签合并到其他窗口时插入到鼠标位置而非总在末尾
This commit is contained in:
parent
089f219280
commit
fc74e0d952
3
electron/electron.js
vendored
3
electron/electron.js
vendored
@ -1532,7 +1532,8 @@ function getAllWebTabWindowsInfo() {
|
|||||||
y: bounds.y,
|
y: bounds.y,
|
||||||
width: bounds.width,
|
width: bounds.width,
|
||||||
height: webTabHeight
|
height: webTabHeight
|
||||||
}
|
},
|
||||||
|
tabCount: windowData.views.length
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -446,12 +446,41 @@
|
|||||||
* 将标签附加到目标窗口
|
* 将标签附加到目标窗口
|
||||||
*/
|
*/
|
||||||
attachToWindow(tabId, targetWindowId, screenX) {
|
attachToWindow(tabId, targetWindowId, screenX) {
|
||||||
// 计算插入位置(可以根据 screenX 确定位置,这里简化处理)
|
// 查找目标窗口信息
|
||||||
|
const targetWindow = this.otherWindows.find(w => w.windowId === targetWindowId)
|
||||||
|
let insertIndex = null
|
||||||
|
|
||||||
|
if (targetWindow && targetWindow.tabCount > 0) {
|
||||||
|
// 计算插入位置
|
||||||
|
// 导航区域宽度(macOS 约 140px,Windows 约 100px)
|
||||||
|
const navAreaWidth = navigator.platform.includes('Mac') ? 140 : 100
|
||||||
|
const tabBarX = targetWindow.tabBarBounds.x
|
||||||
|
const tabBarWidth = targetWindow.tabBarBounds.width
|
||||||
|
const tabCount = targetWindow.tabCount
|
||||||
|
|
||||||
|
// 标签区域的起始位置和宽度
|
||||||
|
const tabAreaStartX = tabBarX + navAreaWidth
|
||||||
|
const tabAreaWidth = tabBarWidth - navAreaWidth - 150 // 减去右侧操作按钮区域
|
||||||
|
|
||||||
|
// 计算每个标签的平均宽度
|
||||||
|
const tabWidth = Math.min(180, tabAreaWidth / tabCount) // 最大标签宽度 180px
|
||||||
|
|
||||||
|
// 鼠标相对于标签区域起始位置的偏移
|
||||||
|
const relativeX = screenX - tabAreaStartX
|
||||||
|
|
||||||
|
if (relativeX <= 0) {
|
||||||
|
insertIndex = 0
|
||||||
|
} else {
|
||||||
|
// 计算鼠标位于第几个标签位置
|
||||||
|
insertIndex = Math.min(Math.floor(relativeX / tabWidth), tabCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.sendMessage('webTabAttach', {
|
this.sendMessage('webTabAttach', {
|
||||||
sourceWindowId: this.windowId,
|
sourceWindowId: this.windowId,
|
||||||
tabId: tabId,
|
tabId,
|
||||||
targetWindowId: targetWindowId,
|
targetWindowId,
|
||||||
insertIndex: null // 追加到末尾
|
insertIndex
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user