diff --git a/android/app/src/main/java/games/wenzi/ogame/MainActivity.java b/android/app/src/main/java/games/wenzi/ogame/MainActivity.java index 9489197..a2586bd 100644 --- a/android/app/src/main/java/games/wenzi/ogame/MainActivity.java +++ b/android/app/src/main/java/games/wenzi/ogame/MainActivity.java @@ -3,6 +3,8 @@ package games.wenzi.ogame; import android.graphics.Color; import android.os.Bundle; import android.view.Window; +import android.webkit.WebSettings; +import android.webkit.WebView; import androidx.core.view.WindowCompat; import androidx.core.view.WindowInsetsControllerCompat; import com.getcapacitor.BridgeActivity; @@ -28,4 +30,15 @@ public class MainActivity extends BridgeActivity { controller.setAppearanceLightNavigationBars(false); } } + + @Override + public void onStart() { + super.onStart(); + // 禁用 WebView 文本缩放,防止系统字体大小设置影响布局 + WebView webView = getBridge().getWebView(); + if (webView != null) { + WebSettings settings = webView.getSettings(); + settings.setTextZoom(100); // 固定为 100%,忽略系统字体缩放设置 + } + } } diff --git a/capacitor.config.ts b/capacitor.config.ts index 2ede4b6..347bd7e 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -11,6 +11,15 @@ const config: CapacitorConfig = { buildOptions: { keystorePath: undefined, keystoreAlias: undefined + }, + // 禁用 WebView 文本缩放,防止系统字体设置影响布局 + webContentsDebuggingEnabled: false, + allowMixedContent: false + }, + plugins: { + // 禁用键盘自动调整视口 + Keyboard: { + resize: 'none' } } } diff --git a/src/style.css b/src/style.css index 5bed97c..87d1739 100644 --- a/src/style.css +++ b/src/style.css @@ -123,6 +123,10 @@ html { /* 平滑过渡 */ transition: background-color 0.3s ease, color 0.3s ease; + /* 禁用文本大小调整,防止移动端自动放大文本 */ + -webkit-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + text-size-adjust: 100%; } body { @@ -217,4 +221,22 @@ aside nav a:hover button { :root:not(.dark) .tooltip-content-custom { background-color: oklch(0.3 0.02 85) !important; color: oklch(0.95 0.008 85) !important; +} + +/* 修复 Edge-to-Edge 模式下 Portal 容器的定位问题 */ +[data-reka-portal], +[data-radix-portal] { + position: fixed !important; + left: 0 !important; + top: 0 !important; + right: 0 !important; + bottom: 0 !important; + pointer-events: none; + padding: 0 !important; + margin: 0 !important; +} + +[data-reka-portal] > *, +[data-radix-portal] > * { + pointer-events: auto; } \ No newline at end of file