feat: per-app initial scale config

This commit is contained in:
2026-08-17 20:01:01 +08:00
parent b65a0400a6
commit bb714d8de3
5 changed files with 23 additions and 12 deletions
@@ -144,7 +144,7 @@ class JsBridge(
// 1. 本地离线包优先(服务端删除后仍可用)
val localUrl = st?.localIndexUrl(id)
if (localUrl != null) {
openWebAppAt(container, host, id, localUrl, app.name, app.ua)
openWebAppAt(container, host, id, localUrl, app.name, app.ua, app.scale)
return
}
// 2. 有离线包 → 后台下载解压(推送进度),完成后加载本地;失败回退远程
@@ -155,24 +155,24 @@ class JsBridge(
val fullUrl = resolveUrl(pkg)
st.downloadAndExtract(id, fullUrl, app.offlineVersion ?: "") { p -> pushWebappProgress(id, p) }
val url = st.localIndexUrl(id) ?: app.url
openWebAppAt(container, host, id, url, app.name, app.ua)
openWebAppAt(container, host, id, url, app.name, app.ua, app.scale)
pushWebappProgress(id, 100)
}.start()
return
}
// 3. 无离线包 → 远程加载(WebView 自带加载进度)
openWebAppAt(container, host, id, app.url, app.name, app.ua)
openWebAppAt(container, host, id, app.url, app.name, app.ua, app.scale)
}
// 在主线程打开指定 url 的 webAPP 标签
// Open a webapp tab at the given url on the main thread
private fun openWebAppAt(container: WebAppContainer, host: WebAppHost, id: String, url: String, name: String, ua: String?) {
private fun openWebAppAt(container: WebAppContainer, host: WebAppHost, id: String, url: String, name: String, ua: String?, scale: Int?) {
onMain {
container.open(id, url, name)
host.openWebView(id, url, ua)
host.openWebView(id, url, ua, scale)
host.syncTabs(container.tabs())
}
Log.d("HearthBridge", "openWebApp: id=$id url=$url ua=$ua")
Log.d("HearthBridge", "openWebApp: id=$id url=$url ua=$ua scale=$scale")
}
// 手动导入离线包(由 MainActivity 触发 SAF 选择 zip