統一天文資料 API - 為 AR Stars 提供資料服務
// 載入索引和目錄
const index = await fetch('/index.json').then(r => r.json());
const catalog = await fetch('/catalog.json').then(r => r.json());
// 搜尋天體
function search(query) {
return index.objects.filter(obj =>
obj.name.toLowerCase().includes(query) ||
obj.name_zh?.includes(query)
);
}
// 載入詳細資料
async function getDetails(type, id) {
const category = getCategoryFolder(type);
const url = `/details/${category}/${id}.json`;
return await fetch(url).then(r => r.json());
}
v2.0 架構採用三層載入設計: