electron-filesystem icon indicating copy to clipboard operation
electron-filesystem copied to clipboard

npm run build之后样式不对

Open luckxiang opened this issue 6 years ago • 3 comments

build打包之后样式比npm run dev调试的时候样式大一些,字体也会大一两号,请问有人遇到过这种情况吗?不知道是本地环境问题还是项目配置本身有问题

luckxiang avatar Aug 31 '18 09:08 luckxiang

问题我自己处理了,主要是屏幕分辨率适配的问题,main.js引入代码如下:

var devInnerHeight = 1080.0 // 开发时的InnerHeight
var devDevicePixelRatio = 1.0// 开发时的devicepixelratio
var devScaleFactor = 1.3 // 开发时的ScaleFactor
var scaleFactor = require('electron').screen.getPrimaryDisplay().scaleFactor
var zoomFactor = (window.innerHeight / devInnerHeight) * (window.devicePixelRatio / devDevicePixelRatio) * (devScaleFactor / scaleFactor)
require('electron').webFrame.setZoomFactor(zoomFactor)

具体可以见我博客 electron-vue打包后样式变大以及不同分辨率屏幕适配问题

luckxiang avatar Sep 01 '18 05:09 luckxiang

请问能发一下完整的解决方法么

WildLight avatar Apr 30 '21 15:04 WildLight

sorry,前面域名换了 main.js中引入如下缩放代码

var devInnerHeight = 1080.0 // 开发时的InnerHeight
var devDevicePixelRatio = 1.0// 开发时的devicepixelratio
var devScaleFactor = 1.3 // 开发时的ScaleFactor
var scaleFactor = require('electron').screen.getPrimaryDisplay().scaleFactor
var zoomFactor = (window.innerHeight / devInnerHeight) * (window.devicePixelRatio / devDevicePixelRatio) * (devScaleFactor / scaleFactor)
require('electron').webFrame.setZoomFactor(zoomFactor)

luckxiang avatar May 11 '21 05:05 luckxiang