mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-29 01:02:47 +08:00
🔨 适配windows 125%下窗口异常
This commit is contained in:
parent
cffbbaf0dc
commit
5eb07118b0
@ -4,12 +4,20 @@ const useDrag = () => {
|
|||||||
let animationId: number;
|
let animationId: number;
|
||||||
let mouseX: number;
|
let mouseX: number;
|
||||||
let mouseY: number;
|
let mouseY: number;
|
||||||
|
let clientWidth = 0;
|
||||||
|
let clientHeight = 0;
|
||||||
let draggable = true;
|
let draggable = true;
|
||||||
|
|
||||||
const onMouseDown = (e) => {
|
const onMouseDown = (e) => {
|
||||||
draggable = true;
|
draggable = true;
|
||||||
mouseX = e.clientX;
|
mouseX = e.clientX;
|
||||||
mouseY = e.clientY;
|
mouseY = e.clientY;
|
||||||
|
if (Math.abs(document.body.clientWidth - clientWidth) > 5) {
|
||||||
|
clientWidth = document.body.clientWidth;
|
||||||
|
}
|
||||||
|
if (Math.abs(document.body.clientHeight - clientHeight) > 5) {
|
||||||
|
clientHeight = document.body.clientHeight;
|
||||||
|
}
|
||||||
document.addEventListener('mouseup', onMouseUp);
|
document.addEventListener('mouseup', onMouseUp);
|
||||||
animationId = requestAnimationFrame(moveWindow);
|
animationId = requestAnimationFrame(moveWindow);
|
||||||
};
|
};
|
||||||
@ -23,7 +31,7 @@ const useDrag = () => {
|
|||||||
const moveWindow = () => {
|
const moveWindow = () => {
|
||||||
ipcRenderer.send('msg-trigger', {
|
ipcRenderer.send('msg-trigger', {
|
||||||
type: 'windowMoving',
|
type: 'windowMoving',
|
||||||
data: { mouseX, mouseY },
|
data: { mouseX, mouseY, width: clientWidth, height: clientHeight },
|
||||||
});
|
});
|
||||||
if (draggable) animationId = requestAnimationFrame(moveWindow);
|
if (draggable) animationId = requestAnimationFrame(moveWindow);
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ class API {
|
|||||||
const { x, y } = screen.getCursorScreenPoint();
|
const { x, y } = screen.getCursorScreenPoint();
|
||||||
const originWindow = this.getCurrentWindow(window, e);
|
const originWindow = this.getCurrentWindow(window, e);
|
||||||
if (!originWindow) return;
|
if (!originWindow) return;
|
||||||
originWindow.setBounds({ x: x - mouseX, y: y - mouseY });
|
originWindow.setBounds({ x: x - mouseX, y: y - mouseY, width, height });
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadPlugin({ data: plugin }, window) {
|
public loadPlugin({ data: plugin }, window) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user