mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-11 23:45:11 +08:00
perf: 优化安卓WebView性能与调试配置
MainActivity中为WebView启用硬件加速、DOM存储、数据库及默认缓存模式,提升性能与兼容性。capacitor.config.ts开启webContentsDebugging,便于调试排查问题。
This commit is contained in:
@@ -34,11 +34,17 @@ public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
// 禁用 WebView 文本缩放,防止系统字体大小设置影响布局
|
||||
WebView webView = getBridge().getWebView();
|
||||
if (webView != null) {
|
||||
WebSettings settings = webView.getSettings();
|
||||
settings.setTextZoom(100); // 固定为 100%,忽略系统字体缩放设置
|
||||
// 禁用 WebView 文本缩放,防止系统字体大小设置影响布局
|
||||
settings.setTextZoom(100);
|
||||
// 优化 WebView 性能
|
||||
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setDatabaseEnabled(true);
|
||||
// 启用硬件加速渲染
|
||||
webView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ const config: CapacitorConfig = {
|
||||
keystorePath: undefined,
|
||||
keystoreAlias: undefined
|
||||
},
|
||||
// 禁用 WebView 文本缩放,防止系统字体设置影响布局
|
||||
webContentsDebuggingEnabled: false,
|
||||
// 启用 WebView 调试,方便排查问题
|
||||
webContentsDebuggingEnabled: true,
|
||||
allowMixedContent: false
|
||||
},
|
||||
plugins: {
|
||||
|
||||
Reference in New Issue
Block a user