同时支持触摸和鼠标事件翻页

This commit is contained in:
xianyi
2025-11-24 09:31:04 +08:00
parent 1bfa9fefe0
commit 88973906a4
2 changed files with 83 additions and 7 deletions

View File

@@ -68,6 +68,19 @@ function createWindow() {
},
});
// 启用触摸事件支持Windows 触摸屏)
mainWindow.webContents.on("did-finish-load", () => {
// 注入触摸事件支持脚本
mainWindow.webContents.executeJavaScript(`
// 确保触摸事件可用
if (navigator.maxTouchPoints === 0) {
console.log('[Electron] 未检测到触摸设备,将使用鼠标事件模拟');
} else {
console.log('[Electron] 检测到触摸设备,触摸点数:', navigator.maxTouchPoints);
}
`).catch(err => log.error("Failed to inject touch support:", err));
});
const isDev = !app.isPackaged;
if (isDev) {