优化滚动条
This commit is contained in:
parent
8fe4a28f4c
commit
b451e694f4
|
|
@ -275,10 +275,31 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun createGeckoRuntime(): GeckoRuntime {
|
||||
val runtime = GeckoRuntime.getDefault(this)
|
||||
runtime.settings.aboutConfigEnabled = true
|
||||
runtime.settings.consoleOutputEnabled = true
|
||||
// 强制清缓存,确保 JS/CSS 等资源获取最新版本
|
||||
// 1. 将配置写入应用的本地沙盒文件 (YAML 格式)
|
||||
val configFile = java.io.File(filesDir, "geckoview-config.yaml")
|
||||
try {
|
||||
val configContent = """
|
||||
prefs:
|
||||
layout.testing.overlay-scrollbars.always-visible: true
|
||||
""".trimIndent()
|
||||
configFile.writeText(configContent)
|
||||
Timber.tag("MainActivity").d("Wrote GeckoView config to: ${configFile.absolutePath}")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").e(e, "Failed to write geckoview-config.yaml")
|
||||
}
|
||||
|
||||
// 2. 通过 GeckoRuntimeSettings.Builder 加载该 YAML 配置文件并创建 GeckoRuntime 实例
|
||||
val settingsBuilder = org.mozilla.geckoview.GeckoRuntimeSettings.Builder()
|
||||
.aboutConfigEnabled(true)
|
||||
.consoleOutput(true)
|
||||
|
||||
if (configFile.exists()) {
|
||||
settingsBuilder.configFilePath(configFile.absolutePath)
|
||||
}
|
||||
|
||||
val runtime = GeckoRuntime.create(this, settingsBuilder.build())
|
||||
|
||||
// 3. 强制清缓存,确保 JS/CSS 等资源获取最新版本
|
||||
try {
|
||||
// runtime.storageController.clearData(ClearFlags.ALL)
|
||||
Timber.tag("MainActivity").i("GeckoView cache cleared")
|
||||
|
|
|
|||
Loading…
Reference in New Issue