无边框
const win = new BrowserWindow({
width: 1290,
height: 736,
minHeight: 736,
minWidth: 1040,
maxHeight: 736,
maxWidth: 1290,
frame: false, // 无边框
webPreferences: {
// preload: process.env.WEBPACK_DEV_SERVER_URL ? __dirname + '/preload.js' : 'app://./preload.js',
// devTools: true,
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: true,
contextIsolation: false
}
})
窗口鼠标拖拽移动
ipcMain.handle("window-move-open", (event, canMoving) => {
let winStartPosition = { x: 0, y: 0 };
let mouseStartPosition = { x: 0, y: 0 };
const currentWindow = BrowserWindow.getFocusedWindow();
const currentWindowSize = currentWindow.getSize();
if (currentWindow) {
if (canMoving) {
const winPosition = currentWindow.getPosition();
winStartPosition = { x: winPosition[0], y: winPosition[1] };
mouseStartPosition = screen.getCursorScreenPoint();
if (movingInterval) {
clearInterval(movingInterval);
}
movingInterval = setInterval(() => {
if (!currentWindow.isDestroyed()) {
if (!currentWindow.isFocused()) {
clearInterval(movingInterval);
movingInterval = null;
}
const cursorPosition = screen.getCursorScreenPoint();
const x =
winStartPosition.x + cursorPosition.x - mouseStartPosition.x;
const y =
winStartPosition.y + cursorPosition.y - mouseStartPosition.y;
currentWindow.setBounds({
x: x,
y: y,
width: currentWindowSize[0],
height: currentWindowSize[1],
});
}
}, 10);
} else {
clearInterval(movingInterval);
movingInterval = null;
}
}
});
调用dll
nodejs调用dll依赖ffi模块,如何安装ffi依赖?
推荐文章地址:https://blog.csdn.net/qq_28218253/article/details/121643328
需要注意的问题:
1.首先要判断dll是32位还是64位?
桌面左下角搜索,输入vs,选择vs开发者命令行工具, 输入dumpbin /headers XXX.dll,
如果是x86 32 bit,则为32位,反之是64
2.根据dll是32位还是64位,选择对应的nodejs版本以及electron。
推荐文章地址:https://blog.csdn.net/qq_28218253/article/details/121643328
3.安装windows-build-tools出现卡住的问题?
推荐文章地址:https://blog.csdn.net/Ajucy/article/details/130380278
如何调用dll
const dllPath = process.cwd()+'\\5.6.0.8_64.dll';
let strPtr = refArray('uchar',16)
const library = ffi.Library(dllPath,{
DyInit: ['int',[]],
DyGetPushStreamUrl:[ref.refType(strPtr),[]],
DyUnInit: ['int',[]],
DyGetVersion: [ref.refType(strPtr),[]],
})
let res = library.DyGetVersion()
console.log(res.toString())
dll函数返回指针数据
推荐文章地址:https://blog.csdn.net/RuanEmpty/article/details/115692244