main.js 中
function updateZoomFactor(targetView) { if (!targetView || !targetView.webContents || targetView.webContents.isDestroyed()) { return; } const viewBounds = targetView.getBounds(); const viewWidth = viewBounds.width; if (viewWidth > 0) { const idealWidth = 1400; // Assumed ideal width for video websites const zoomFactor = viewWidth / idealWidth; targetView.webContents.setZoomFactor(zoomFactor); console.log([Zoom] View width is ${viewWidth}, setting zoom to ${zoomFactor.toFixed(2)}); } }
如果分辨率是3440 的宽屏显示器 会得到3440/1400 =2.45 的放大率 , 这样会使3440x1440 用户 UI 横向过大 竖向内容不够 ,影响使用 ,建议限制大小
main.js 中
function updateZoomFactor(targetView) { if (!targetView || !targetView.webContents || targetView.webContents.isDestroyed()) { return; } const viewBounds = targetView.getBounds(); const viewWidth = viewBounds.width; if (viewWidth > 0) { const idealWidth = 1400; // Assumed ideal width for video websites const zoomFactor = viewWidth / idealWidth; targetView.webContents.setZoomFactor(zoomFactor); console.log([Zoom] View width is ${viewWidth}, setting zoom to ${zoomFactor.toFixed(2)}); } }如果分辨率是3440 的宽屏显示器 会得到3440/1400 =2.45 的放大率 , 这样会使3440x1440 用户 UI 横向过大 竖向内容不够 ,影响使用 ,建议限制大小