fix: handle GitHub fallback response format {repos, fallback}
This commit is contained in:
parent
d39c0d58fd
commit
f40a6df041
|
|
@ -2057,7 +2057,9 @@ async function runGithubScan() {
|
||||||
const url = `${apiBase}/atlas/github-scan?token=${encodeURIComponent(token)}${org ? '&org=' + encodeURIComponent(org) : ''}`;
|
const url = `${apiBase}/atlas/github-scan?token=${encodeURIComponent(token)}${org ? '&org=' + encodeURIComponent(org) : ''}`;
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `HTTP ${res.status}`); }
|
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `HTTP ${res.status}`); }
|
||||||
const repos = await res.json();
|
const raw = await res.json();
|
||||||
|
const repos = Array.isArray(raw) ? raw : (raw.repos || []);
|
||||||
|
const isFallback = !Array.isArray(raw) && raw.fallback;
|
||||||
|
|
||||||
let added = 0;
|
let added = 0;
|
||||||
// Add GitHub org/user as cloud node if not present
|
// Add GitHub org/user as cloud node if not present
|
||||||
|
|
@ -2090,8 +2092,9 @@ async function runGithubScan() {
|
||||||
initGraph();
|
initGraph();
|
||||||
setTimeout(fitGraph, 500);
|
setTimeout(fitGraph, 500);
|
||||||
statusEl.className = 'scan-status visible ok';
|
statusEl.className = 'scan-status visible ok';
|
||||||
statusEl.textContent = `${repos.length} リポジトリ検出 — ${added} 件追加`;
|
const fallbackNote = isFallback ? ' (ユーザーリポジトリにフォールバック)' : '';
|
||||||
showToast(`GitHub: ${added} リポジトリを追加しました`);
|
statusEl.textContent = `${repos.length} リポジトリ検出 — ${added} 件追加${fallbackNote}`;
|
||||||
|
showToast(`GitHub: ${added} リポジトリを追加しました${fallbackNote}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
statusEl.className = 'scan-status visible err';
|
statusEl.className = 'scan-status visible err';
|
||||||
statusEl.textContent = `エラー: ${e.message}`;
|
statusEl.textContent = `エラー: ${e.message}`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue