修改页面大小

This commit is contained in:
zm2000 2026-09-20 22:57:22 +08:00
parent bf09fed301
commit 4071acca9e
11 changed files with 141 additions and 3495 deletions

View File

@ -28,7 +28,7 @@ console 转发原理(release 包 console 默认不进 logcat):
### 根因
- reLaunch 创建的新页面 WebView 初始**视口为 0×0**(`window.innerWidth/innerHeight` 都是 0,`document.body` 尺寸 0×0);
- 全局 CSS 的 `html { font-size: min(3.515625vw, 5.2734375vh) }` 依赖视口,视口为 0 时 fontSize 计算为 **0px**;
- 全局 CSS 的 `html { font-size: min(5.2734375vw, 7.91015625vh) }` 依赖视口,视口为 0 时 fontSize 计算为 **0px**;
- 本项目全站用 rem 布局,fontSize=0 → 所有 rem 尺寸归零 → 白屏;
- 切后台回前台时 Activity resume 触发原生重排,视口恢复(961×640 CSS 像素,dpr=2 对应物理 1920×1280),页面随即正常。

View File

@ -37,29 +37,57 @@ $apkSource = Join-Path $asDir "$module\build\outputs\apk\release\$module-relea
$buildGradle = Join-Path $asDir "$module\build.gradle"
$configPath = Join-Path $projRoot 'config\android.json'
# ============ JDK detect ============
if (-not $JavaHome -and $env:JAVA_HOME) { $JavaHome = $env:JAVA_HOME }
if (-not $JavaHome) {
$javaCandidates = @(
"$env:LOCALAPPDATA\Programs\EclipseAdoptium",
"$env:LOCALAPPDATA\Programs\Android Studio\jbr",
"C:\Program Files\Android\Android Studio\jbr",
"D:\Program Files\Android\Android Studio\jbr",
"$env:USERPROFILE\.jdks",
"C:\Program Files\Java",
"C:\Program Files\Eclipse Adoptium"
)
foreach ($c in $javaCandidates) {
$javaExe = Get-ChildItem $c -Recurse -Filter java.exe -ErrorAction SilentlyContinue | Select-Object -First 1
if ($javaExe) { $JavaHome = $javaExe.Directory.Parent.FullName; break }
# ============ JDK detect (JDK 17+ required) ============
function Get-JavaMajorVersion([string]$javaExe) {
$prev = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
$out = (cmd /c "`"$javaExe`" -version 2>&1" | Out-String)
} finally {
$ErrorActionPreference = $prev
}
if ($out -match 'version\s+"1\.(\d+)') { return [int]$Matches[1] }
if ($out -match 'version\s+"(\d+)') { return [int]$Matches[1] }
return 0
}
$jdkCandidates = @()
if ($JavaHome) { $jdkCandidates += $JavaHome }
if ($env:JAVA_HOME) { $jdkCandidates += $env:JAVA_HOME }
$jdkCandidates += @(
"$env:LOCALAPPDATA\Programs\EclipseAdoptium",
"$env:LOCALAPPDATA\Programs\Android Studio\jbr",
"C:\Program Files\Android\Android Studio\jbr",
"D:\Program Files\Android\Android Studio\jbr",
"$env:USERPROFILE\.jdks",
"C:\Program Files\Java",
"C:\Program Files\Eclipse Adoptium"
)
$selectedJava = ""
foreach ($c in $jdkCandidates) {
if (-not $c) { continue }
$javaExe = Join-Path $c 'bin\java.exe'
if (-not (Test-Path $javaExe)) {
$found = Get-ChildItem $c -Recurse -Filter java.exe -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $javaExe = $found.FullName }
}
if (Test-Path $javaExe) {
$major = Get-JavaMajorVersion $javaExe
if ($major -ge 17) {
$selectedJava = Split-Path -Parent (Split-Path -Parent $javaExe)
break
}
}
}
if ($JavaHome -and (Test-Path (Join-Path $JavaHome 'bin\java.exe'))) {
if ($selectedJava -and (Test-Path (Join-Path $selectedJava 'bin\java.exe'))) {
$JavaHome = $selectedJava
$env:JAVA_HOME = $JavaHome
$env:Path = "$JavaHome\bin;$env:Path"
} else {
Write-Host ""
Write-Host "[error] JDK not found. JDK 17+ required. Set JAVA_HOME or use -JavaHome." -ForegroundColor Red
Write-Host "[error] JDK 17+ not found. Install JDK 17+ (or Android Studio JBR) or use -JavaHome '...'." -ForegroundColor Red
exit 1
}
@ -69,7 +97,7 @@ if (-not $AndroidSdk) { $AndroidSdk = $env:ANDROID_SDK_ROOT }
$localProps = Join-Path $asDir 'local.properties'
if (-not $AndroidSdk -and (Test-Path $localProps)) {
$line = Select-String -Path $localProps -Pattern '^sdk\.dir=(.+)$'
if ($line) { $AndroidSdk = $line.Matches[0].Groups[1].Value -replace '\:', ':' -replace '\\\\', '\' }
if ($line) { $AndroidSdk = [regex]::Replace($line.Matches[0].Groups[1].Value, '\\([\\:])', '$1') }
}
if (-not $AndroidSdk -or -not (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
$sdkCandidates = @(
@ -85,7 +113,7 @@ if (-not $AndroidSdk -or -not (Test-Path (Join-Path $AndroidSdk 'platform-tools'
if ($AndroidSdk -and (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
$env:ANDROID_HOME = $AndroidSdk
$env:ANDROID_SDK_ROOT = $AndroidSdk
$escaped = ($AndroidSdk -replace '\\', '\\' -replace ':', '\:')
$escaped = $AndroidSdk -replace '\\', '\\'
$sdkLine = "sdk.dir=$escaped"
if (Test-Path $localProps) {
$props = Get-Content $localProps -Raw

View File

@ -1,6 +1,6 @@
{
"name": "wms-worker-station",
"version": "1.0.20",
"version": "1.0.24",
"description": "WMS仓库工作台桌面端",
"author": "tianbao",
"main": "electron/main.js",

View File

@ -5,9 +5,9 @@ const DESIGN_WIDTH = 1920
const DESIGN_HEIGHT = 1280
const BASE_FONT_SIZE = 100
// 整体缩放系数:<1 整体缩小,>1 整体放大(布局偏大就调小这个值)
// 0.45 平板触摸尺寸基准偏大;桌面 H5/Electron(1920×1080)统一调整为 0.28
// 真机 APP-PLUS 的 rem 由下方全局纯 CSS 承担(0.675 系数,修复真机退出登录后白屏),JS 仅 H5 参与计算
const REM_SCALE = 0.28
// 0.45 平板触摸尺寸基准偏大;桌面 H5/Electron(1920×1080)统一调整为 0.42(0.28 基础上整体放大 50%)
// 真机 APP-PLUS 的 rem 由下方全局纯 CSS 承担(2.5vw,框架锁死 16px 基础上整体放大 50% → 24px),JS 仅 H5 参与计算
const REM_SCALE = 0.42
// #ifdef APP-PLUS
// 打开应用后将系统音量调至最大(仓库环境语音播报需要;setStreamVolume 无需额外权限)
@ -113,13 +113,26 @@ export default {
<style>
/*每个页面公共css */
/* rem 基准:设计稿 1920×1280,REM_SCALE=0.675
fontSize = min(w/1920, h/1280) × 67.5px = min(3.515625vw, 5.2734375vh)
纯 CSS 实现,首帧即正确,不依赖 renderjs 时序(修复真机退出登录后白屏) */
/* rem 基准:设计稿 1920×1280,100px = 1rem(min(w/1920, h/1280) × 100)
H5/Electron:由 setRemBase()(JS,REM_SCALE=0.42)以内联样式运行时计算,此处仅首帧兜底;
真机 APP-PLUS:由下方 #ifdef APP-PLUS 的 !important 规则承担(见下) */
html {
font-size: min(3.515625vw, 5.2734375vh);
font-size: min(5.2734375vw, 7.91015625vh);
}
/* #ifdef APP-PLUS */
/* 真机修复:uni-app 框架(uni-app-view.umd.js)运行时把 html font-size 以内联样式锁为
窗口宽度/23.4375;真机 innerWidth=961 刚好超过框架 rpxCalcMaxDeviceWidth=960 →
走 base 375 → 16px。内联样式优先级高于普通样式表,故上面的 CSS 对真机无效。
用 !important 让样式表反超非 important 的内联样式。
目标:在框架锁死的 16px 基础上整体放大 50% → 24px = 2.5vw。
横屏锁定 960×640(3:2) 与设计稿 1920×1280(3:2) 同比例,vw 与 min(vw,vh) 等价;
老 WebView 可能不支持 CSS min(),故直接用 vw。 */
html {
font-size: 2.5vw !important;
}
/* #endif */
/* H5/Electron 下 picker 下拉弹窗宽度与触发下拉框一致(高特异性覆盖库默认 300px),阴影调淡 */
uni-picker .uni-picker-container .uni-picker-custom,
.uni-picker-container .uni-picker-custom.uni-picker-custom {

View File

@ -15,8 +15,21 @@ const isApp = true
const isApp = false
// #endif
// 应用版本(构建时由 vite define 从 package.json 注入)
const version = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0'
// 应用版本:
// - Web/桌面端:构建时由 vite define 从 package.json 注入(__APP_VERSION__)
// - App 端:优先读取真实 APK 的 versionName(plus.runtime.version,由 Gradle 构建时从 package.json 注入),
// 避免「build:app 产物里烘焙的版本」与「最终 APK 版本」错位(先 build:app 后改版本号再打包时,
// 产物文件名已是新版本,但 JS 里仍是旧版本,导致 PDA 上报/更新检测用错版本号)
let version = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0'
// #ifdef APP-PLUS
try {
if (typeof plus !== 'undefined' && plus.runtime && plus.runtime.version) {
version = plus.runtime.version
}
} catch (e) {
// plus 未就绪时回退到构建期注入的版本
}
// #endif
// 打包类型:electron=桌面端 / android=App / web=浏览器
const packType = isElectron ? 'electron' : isApp ? 'android' : 'web'
const packTypeLabel = isElectron ? '桌面端' : isApp ? 'Android端' : 'Web端'

View File

@ -234,12 +234,12 @@ export default {
export default {
mounted() {
// #ifdef APP-PLUS
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(3.515625vw, 5.2734375vh) },0.675 系数)承担,
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
return
// #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.28
const REM_SCALE = 0.28
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920

View File

@ -1850,12 +1850,12 @@ export default {
export default {
mounted() {
// #ifdef APP-PLUS
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(3.515625vw, 5.2734375vh) },0.675 系数)承担,
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
return
// #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.28
const REM_SCALE = 0.28
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920

View File

@ -3154,12 +3154,12 @@ export default {
export default {
mounted() {
// #ifdef APP-PLUS
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(3.515625vw, 5.2734375vh) },0.675 系数)承担,
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
return
// #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.28
const REM_SCALE = 0.28
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920

View File

@ -34,7 +34,7 @@
</view>
<view v-else class="pack-layout">
<!-- 左面板 70% -->
<!-- 左面板 65% -->
<view class="pack-left">
<view class="pack-search">
<input
@ -137,7 +137,7 @@
</view>
</view>
<!-- 右面板 30% -->
<!-- 右面板 35% -->
<view class="pack-right">
<view class="pack-card pack-today">
<text class="pack-card-title">今日打包</text>
@ -2929,20 +2929,27 @@ export default {
installZeroViewportFix()
try {
const Log = plus.android.importClass('android.util.Log')
Log.i('WMSView', 'renderjs mounted, body=' + (document.body ? document.body.clientWidth + 'x' + document.body.clientHeight : 'null') + ', inner=' + window.innerWidth + 'x' + window.innerHeight + ', fontSize=' + (document.documentElement.style ? document.documentElement.style.fontSize : 'na'))
const computedFont = () => {
let css = 'na'
try {
css = window.getComputedStyle(document.documentElement).fontSize
} catch (e) { /* ignore */ }
return css
}
Log.i('WMSView', 'renderjs mounted, body=' + (document.body ? document.body.clientWidth + 'x' + document.body.clientHeight : 'null') + ', inner=' + window.innerWidth + 'x' + window.innerHeight + ', inlineFont=' + (document.documentElement.style ? document.documentElement.style.fontSize : 'na') + ', computedFont=' + computedFont())
setTimeout(() => {
Log.i('WMSView', 'renderjs t+2s, body=' + (document.body ? document.body.clientWidth + 'x' + document.body.clientHeight : 'null') + ', inner=' + window.innerWidth + 'x' + window.innerHeight + ', fontSize=' + (document.documentElement.style ? document.documentElement.style.fontSize : 'na'))
Log.i('WMSView', 'renderjs t+2s, body=' + (document.body ? document.body.clientWidth + 'x' + document.body.clientHeight : 'null') + ', inner=' + window.innerWidth + 'x' + window.innerHeight + ', inlineFont=' + (document.documentElement.style ? document.documentElement.style.fontSize : 'na') + ', computedFont=' + computedFont())
}, 2000)
} catch (e) {
const Log2 = plus.android.importClass('android.util.Log')
Log2.i('WMSView', 'renderjs err=' + e)
}
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(3.515625vw, 5.2734375vh) },0.675 系数)承担,
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
return
// #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.28
const REM_SCALE = 0.28
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920
@ -3177,7 +3184,7 @@ export default {
}
.pack-left {
flex: 7;
flex: 13;
min-width: 0;
min-height: 0;
display: flex;
@ -3209,7 +3216,7 @@ export default {
}
.pack-right {
flex: 3;
flex: 7;
min-width: 0;
min-height: 0;
display: flex;
@ -3611,13 +3618,13 @@ export default {
}
.pack-stat-num {
font-size: 1.024rem;
font-size: 0.922rem;
font-weight: 700;
color: #2f7dff;
}
.pack-stat-label {
font-size: 0.717rem;
font-size: 0.666rem;
color: #888;
margin-top: 0.205rem;
}

File diff suppressed because it is too large Load Diff

View File

@ -34,12 +34,12 @@ export default {
export default {
mounted() {
// #ifdef APP-PLUS
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(3.515625vw, 5.2734375vh) },0.675 系数)承担,
// 真机 rem 由 App.vue 全局纯 CSS(html { font-size: min(5.2734375vw, 7.91015625vh) },1.0125 系数)承担,
// renderjs 不再覆盖,避免与 CSS 方案互相覆盖导致白屏/抖动
return
// #endif
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.28
const REM_SCALE = 0.28
// 整体缩放系数:<1 缩小,>1 放大(布局偏大就调小);0.45 平板基准偏大,H5/Electron 桌面统一 0.42(0.28 基础上整体放大 50%)
const REM_SCALE = 0.42
const setFontSize = () => {
const docEl = document.documentElement
const width = docEl.clientWidth || window.innerWidth || 1920