feat: card repository and home three-column layout
This commit is contained in:
@@ -2,6 +2,8 @@ package top.yeij.hearth.webview
|
||||
|
||||
import android.util.Log
|
||||
import top.yeij.hearth.app.AppRepository
|
||||
import top.yeij.hearth.card.Card
|
||||
import top.yeij.hearth.card.CardRepository
|
||||
import top.yeij.hearth.webapp.WebApp
|
||||
import top.yeij.hearth.webapp.WebAppRepository
|
||||
|
||||
@@ -12,6 +14,7 @@ class JsBridge(
|
||||
private val darkMode: Boolean,
|
||||
private val appRepository: AppRepository? = null,
|
||||
private val webAppRepository: WebAppRepository? = null,
|
||||
private val cardRepository: CardRepository? = null,
|
||||
) {
|
||||
private val gson = com.google.gson.Gson()
|
||||
|
||||
@@ -42,4 +45,14 @@ class JsBridge(
|
||||
// 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>())
|
||||
|
||||
// 返回首页卡片目录 JSON(无仓库时返回空数组;有仓库时由 fetchCatalog 保证内置 time 卡)
|
||||
// Return the home card catalog JSON (empty array when no repository wired;
|
||||
// fetchCatalog guarantees the builtin time card when wired)
|
||||
@android.webkit.JavascriptInterface
|
||||
fun fetchCards(): String {
|
||||
val cards = cardRepository?.fetchCatalog() ?: emptyList<Card>()
|
||||
Log.d("HearthBridge", "fetchCards: ${cards.size} cards")
|
||||
return gson.toJson(cards)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user