This commit is contained in:
parent
1da8168558
commit
cd09ed6429
|
|
@ -9,6 +9,7 @@ import org.mozilla.geckoview.GeckoRuntime
|
|||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSessionSettings
|
||||
import org.mozilla.geckoview.GeckoView
|
||||
import org.mozilla.geckoview.StorageController.ClearFlags
|
||||
import org.mozilla.geckoview.WebRequestError
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
@JvmStatic
|
||||
fun executeJs(script: String) {
|
||||
Timber.tag("ExecuteJs").d(script)
|
||||
synchronized(pendingJsCode ?: Any()) {
|
||||
// 合并多次调用(用换行分隔)
|
||||
pendingJsCode = if (pendingJsCode != null) "$pendingJsCode;$script" else script
|
||||
|
|
@ -197,6 +199,13 @@ class MainActivity : AppCompatActivity() {
|
|||
val runtime = GeckoRuntime.getDefault(this)
|
||||
runtime.settings.aboutConfigEnabled = true
|
||||
runtime.settings.consoleOutputEnabled = true
|
||||
// 强制清缓存,确保 JS/CSS 等资源获取最新版本
|
||||
try {
|
||||
// runtime.storageController.clearData(ClearFlags.ALL)
|
||||
Timber.tag("MainActivity").i("GeckoView cache cleared")
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("MainActivity").w(e, "Failed to clear GeckoView cache")
|
||||
}
|
||||
return runtime
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue