fix: fetch manifest from <server>/manifest.json

This commit is contained in:
2026-08-17 19:41:08 +08:00
parent 2d2dee5e51
commit a35a5018b7
2 changed files with 10 additions and 7 deletions
@@ -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)
}
}
@@ -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<WebApp> {
// 服务器地址是根目录,清单固定拉 <根>/manifest.json
// The server URL is the root; the manifest is always <root>/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) {