From a35a5018b77485e8f9d63ddf733f3e0fe0b9953f Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 17 Aug 2026 19:41:08 +0800 Subject: [PATCH] fix: fetch manifest from /manifest.json --- app/src/main/java/top/yeij/hearth/MainActivity.kt | 2 +- .../top/yeij/hearth/webapp/WebAppRepository.kt | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/top/yeij/hearth/MainActivity.kt b/app/src/main/java/top/yeij/hearth/MainActivity.kt index 3420136..9497918 100644 --- a/app/src/main/java/top/yeij/hearth/MainActivity.kt +++ b/app/src/main/java/top/yeij/hearth/MainActivity.kt @@ -131,7 +131,7 @@ class MainActivity : Activity() { override fun setServerUrl(url: String) { prefs.edit().putString("server_url", url).apply() - if (::webAppRepository.isInitialized) webAppRepository.setManifestUrl(url) + if (::webAppRepository.isInitialized) webAppRepository.setServerUrl(url) } } diff --git a/app/src/main/java/top/yeij/hearth/webapp/WebAppRepository.kt b/app/src/main/java/top/yeij/hearth/webapp/WebAppRepository.kt index f0fb72e..42afb3d 100644 --- a/app/src/main/java/top/yeij/hearth/webapp/WebAppRepository.kt +++ b/app/src/main/java/top/yeij/hearth/webapp/WebAppRepository.kt @@ -28,18 +28,21 @@ interface HttpClient { class WebAppRepository( private val http: HttpClient, private val cache: CacheManager, - private var manifestUrl: String, + private var serverUrl: String, ) { private val gson = Gson() - // 更新清单地址(设置页修改服务器地址后调用) - // Update the manifest URL (called after the settings page changes the server URL) - fun setManifestUrl(url: String) { - manifestUrl = url - Log.d(TAG, "setManifestUrl: $url") + // 更新服务器根地址(设置页修改服务器地址后调用) + // Update the server root URL (called after the settings page changes it) + fun setServerUrl(url: String) { + serverUrl = url + Log.d(TAG, "setServerUrl: $url") } fun fetchManifest(): List { + // 服务器地址是根目录,清单固定拉 <根>/manifest.json + // The server URL is the root; the manifest is always /manifest.json + val manifestUrl = serverUrl.trimEnd('/') + "/manifest.json" val body = http.get(manifestUrl) Log.d(TAG, "fetchManifest: url=$manifestUrl bodyNull=${body == null}") if (body != null) {