feat: h5 webapp list page with rich cards

This commit is contained in:
2026-08-16 16:27:49 +08:00
parent f3405e003f
commit ce55905e59
5 changed files with 78 additions and 2 deletions
@@ -2,6 +2,8 @@ package top.yeij.hearth.webview
import android.util.Log
import top.yeij.hearth.app.AppRepository
import top.yeij.hearth.webapp.WebApp
import top.yeij.hearth.webapp.WebAppRepository
class JsBridge(
private val deviceWidthPx: Int,
@@ -9,6 +11,7 @@ class JsBridge(
private val density: Float,
private val darkMode: Boolean,
private val appRepository: AppRepository? = null,
private val webAppRepository: WebAppRepository? = null,
) {
private val gson = com.google.gson.Gson()
@@ -34,4 +37,9 @@ class JsBridge(
// Launch an app by package name, true on success (false when no repository wired)
@android.webkit.JavascriptInterface
fun launchApp(packageName: String): Boolean = appRepository?.launchApp(packageName) ?: false
// 返回 H5 应用清单 JSON(无仓库时返回空数组)
// Return the H5 web app manifest JSON (empty array when no repository wired)
@android.webkit.JavascriptInterface
fun fetchWebApps(): String = gson.toJson(webAppRepository?.fetchManifest() ?: emptyList<WebApp>())
}