支持图源切换

This commit is contained in:
2026-06-06 01:49:05 +08:00
parent 0f9cb3eae5
commit 71282f4e4f
11 changed files with 358 additions and 7 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
import { getDefaultMapSource } from './api'
import { getDefaultMapSource, getEnabledMapSources } from './api'
import type { PublicMapTileSource } from './types'
export const fallbackMapSource: PublicMapTileSource = {
@@ -17,3 +17,12 @@ export async function loadDefaultMapSource(): Promise<PublicMapTileSource> {
return fallbackMapSource
}
}
export async function loadEnabledMapSources(): Promise<PublicMapTileSource[]> {
try {
const response = await getEnabledMapSources()
return response.items.length > 0 ? response.items : [fallbackMapSource]
} catch {
return [fallbackMapSource]
}
}