先吐槽一下, 有些特定需求是没有直接的 API 的, 必须自己来通过原 API 封装
直接用关键词在网上搜, 给出来的搜索结果真的大都是乱七八糟
目录 Index
- screen 篇
screen 篇
- getCurrentDisplay 想要在多屏幕情况下, 获取当前屏幕
getCurrentDisplay 想要在多屏幕情况下, 获取当前屏幕
/**
* 主要是为了多屏幕情况下, 获取当前屏幕
* { ds, x, y } = config
* ds: Array<any> 由 screen.getAllDisplays() 获得
* x: number 当前 x
* y: number 当前 y
*/
const getCurrentDisplay = (config) => {
const { ds, x, y } = config;
return ds.filter((d) => {
const { bounds, size } = d;
// bx <= x <= bx + bw && by <= y <= by + bh
return bounds.x <= x && x <= bounds.x + size.width && bounds.y <= y && y <= bounds.y + size.height;
})[0];
};