diff --git a/index.html b/index.html index 2880d4a..c9ef59c 100644 --- a/index.html +++ b/index.html @@ -228,7 +228,14 @@
入力
- +
+ + +
@@ -477,6 +484,56 @@ document.getElementById('copyBtn').addEventListener('click', async () => { } }); +// ── コミット読み込み ────────────────── +document.getElementById('loadCommitsBtn').addEventListener('click', async () => { + const token = getToken(); + if (!token) { showToast('ログインが必要です'); return; } + + const btn = document.getElementById('loadCommitsBtn'); + btn.disabled = true; + btn.innerHTML = ' 読み込み中'; + + try { + const resp = await fetch(`${API}/chronicle/activity?days=${activeDays}`, { + headers: { 'Authorization': `Bearer ${token}` } + }); + + if (resp.status === 503) { + showToast('VPS に CHRONICLE_GITHUB_TOKEN が未設定です'); + return; + } + if (!resp.ok) throw new Error(`HTTP ${resp.status}`); + + const data = await resp.json(); + if (!data.commits?.length) { + showToast('この期間にコミットが見つかりませんでした'); + return; + } + + const byRepo = {}; + for (const c of data.commits) { + if (!byRepo[c.repo]) byRepo[c.repo] = []; + byRepo[c.repo].push(c.message); + } + + const lines = []; + for (const [repo, messages] of Object.entries(byRepo)) { + lines.push(`【${repo}】`); + for (const m of messages) lines.push(`- ${m}`); + } + + const area = document.getElementById('activities'); + area.value = lines.join('\n'); + showToast(`${data.commits.length} 件のコミットを読み込みました`); + } catch (e) { + showToast(`読み込み失敗: ${e.message}`); + } finally { + btn.disabled = false; + btn.innerHTML = ' コミットから読み込む'; + lucide.createIcons(); + } +}); + // ── Toast ───────────────────────────── function showToast(msg) { const el = document.getElementById('toast'); diff --git a/vercel.json b/vercel.json index 8dc9043..44704f6 100644 --- a/vercel.json +++ b/vercel.json @@ -30,7 +30,7 @@ }, { "key": "Content-Security-Policy", - "value": "default-src 'self'; script-src 'self' 'unsafe-inline' https://unpkg.com https://posimai-ui.vercel.app; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.gstatic.com https://posimai-ui.vercel.app; font-src 'self' data: https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.soar-enrich.com; worker-src 'self'; frame-ancestors 'none';" + "value": "default-src 'self'; script-src 'self' 'unsafe-inline' https://unpkg.com https://posimai-ui.vercel.app; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.gstatic.com https://posimai-ui.vercel.app; font-src 'self' data: https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.soar-enrich.com https://api.github.com; worker-src 'self'; frame-ancestors 'none';" }, { "key": "Strict-Transport-Security",