-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12ccb61
commit 2cd1def
Showing
9 changed files
with
151 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { load, open, DataType } = require("./index"); | ||
|
||
// 定义 CGRect 结构体 | ||
const CGRect = { | ||
origin: { | ||
x: DataType.Double, | ||
y: DataType.Double, | ||
ffiTypeTag: DataType.StackStruct, | ||
}, | ||
size: { | ||
width: DataType.Double, | ||
height: DataType.Double, | ||
ffiTypeTag: DataType.StackStruct, | ||
}, | ||
ffiTypeTag: DataType.StackStruct, | ||
}; | ||
|
||
// 获取主屏幕尺寸的函数 | ||
const getMainDisplaySize = async () => { | ||
open({ | ||
library: "ApplicationServices", | ||
path: "/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices", | ||
}); | ||
|
||
const bounds = await load({ | ||
library: "ApplicationServices", | ||
funcName: "CGDisplayBounds", | ||
paramsType: [DataType.I32], // 不支持 U32 ,使用 I32 报错 | ||
paramsValue: [1], | ||
retType: CGRect, | ||
}); | ||
return bounds; | ||
}; | ||
|
||
if (process.platform === "darwin") { | ||
getMainDisplaySize().then(console.log); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -583,4 +583,4 @@ const unitTest = () => { | |
|
||
unitTest(); | ||
|
||
exports.unitTest = unitTest; | ||
exports.unitTest = unitTest; |