From 4a5e695fa84e68f3afa2f9af4d185869e7b8f04f Mon Sep 17 00:00:00 2001 From: posimai Date: Fri, 24 Apr 2026 06:53:18 +0900 Subject: [PATCH] =?UTF-8?q?feat(chronicle):=20=E3=82=B3=E3=83=9F=E3=83=83?= =?UTF-8?q?=E3=83=88=E8=87=AA=E5=8B=95=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=81=BF?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E8=BF=BD=E5=8A=A0=EF=BC=88VPS=20/ch?= =?UTF-8?q?ronicle/activity=20=E7=B5=8C=E7=94=B1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++- vercel.json | 2 +- 2 files changed, 59 insertions(+), 2 deletions(-) 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",