feat: log export to Download

This commit is contained in:
2026-08-17 19:25:43 +08:00
parent d9a0342271
commit 31107fddd5
4 changed files with 63 additions and 0 deletions
@@ -81,6 +81,9 @@ class JsBridge(
// 手动导入离线包回调:由 MainActivity 实现(SAF 选择 zip 后导入)
// Manual offline-package import callback implemented by MainActivity (SAF pick + import)
private val onImportOfflinePackage: ((String) -> Unit)? = null,
// 导出日志回调:由 MainActivity 实现,返回导出结果描述(文件名/错误)
// Export-log callback implemented by MainActivity, returns a result description
private val onExportLog: (() -> String)? = null,
) {
private val gson = com.google.gson.Gson()
@@ -185,6 +188,14 @@ class JsBridge(
@android.webkit.JavascriptInterface
fun hasLocalPackage(id: String): Boolean = storage?.hasLocalPackage(id) ?: false
// 导出日志到 Download 目录,返回结果描述(文件名或错误)
// Export the log to the Download directory, return a result description
@android.webkit.JavascriptInterface
fun exportLog(): String {
Log.d("HearthBridge", "exportLog called")
return onExportLog?.invoke() ?: "日志导出未实现"
}
// 本地离线包版本号(无则空字符串)
// Local offline-package version (empty string when absent)
@android.webkit.JavascriptInterface