mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 16:05:12 +08:00
fix: 禁用WebView文本缩放并修复Portal定位
安卓端MainActivity中强制WebView文本缩放为100%,防止系统字体大小影响布局。capacitor.config.ts同步禁用WebView文本缩放及键盘视口调整。CSS中统一禁用文本大小调整,修复Edge-to-Edge模式下Portal容器定位问题,提升移动端显示一致性。
This commit is contained in:
@@ -3,6 +3,8 @@ package games.wenzi.ogame;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
import androidx.core.view.WindowCompat;
|
import androidx.core.view.WindowCompat;
|
||||||
import androidx.core.view.WindowInsetsControllerCompat;
|
import androidx.core.view.WindowInsetsControllerCompat;
|
||||||
import com.getcapacitor.BridgeActivity;
|
import com.getcapacitor.BridgeActivity;
|
||||||
@@ -28,4 +30,15 @@ public class MainActivity extends BridgeActivity {
|
|||||||
controller.setAppearanceLightNavigationBars(false);
|
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%,忽略系统字体缩放设置
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ const config: CapacitorConfig = {
|
|||||||
buildOptions: {
|
buildOptions: {
|
||||||
keystorePath: undefined,
|
keystorePath: undefined,
|
||||||
keystoreAlias: undefined
|
keystoreAlias: undefined
|
||||||
|
},
|
||||||
|
// 禁用 WebView 文本缩放,防止系统字体设置影响布局
|
||||||
|
webContentsDebuggingEnabled: false,
|
||||||
|
allowMixedContent: false
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
// 禁用键盘自动调整视口
|
||||||
|
Keyboard: {
|
||||||
|
resize: 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,10 @@
|
|||||||
html {
|
html {
|
||||||
/* 平滑过渡 */
|
/* 平滑过渡 */
|
||||||
transition: background-color 0.3s ease, color 0.3s ease;
|
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 {
|
body {
|
||||||
@@ -218,3 +222,21 @@ aside nav a:hover button {
|
|||||||
background-color: oklch(0.3 0.02 85) !important;
|
background-color: oklch(0.3 0.02 85) !important;
|
||||||
color: oklch(0.95 0.008 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user