feat(atlas): persist API tokens in localStorage across reloads

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
posimai 2026-03-31 09:24:54 +09:00
parent d85cfbe1be
commit 538cbc582c
1 changed files with 20 additions and 0 deletions

View File

@ -2306,6 +2306,26 @@ function bindEvents() {
location.reload();
});
// ── API キーの永続化 ──────────────────────────────────────
const TOKEN_KEYS = {
'tailscale-token-input': 'posimai-atlas-token-tailscale',
'github-token-input': 'posimai-atlas-token-github',
'github-org-input': 'posimai-atlas-token-github-org',
'vercel-token-input': 'posimai-atlas-token-vercel',
};
// ページロード時に復元
Object.entries(TOKEN_KEYS).forEach(([id, key]) => {
const val = localStorage.getItem(key);
if (val) document.getElementById(id).value = val;
});
// 入力のたびに保存
Object.entries(TOKEN_KEYS).forEach(([id, key]) => {
document.getElementById(id).addEventListener('input', e => {
if (e.target.value) localStorage.setItem(key, e.target.value);
else localStorage.removeItem(key);
});
});
document.getElementById('btnTailscaleScan').addEventListener('click', runTailscaleScan);
document.getElementById('tailscale-token-input').addEventListener('keydown', e => {
if (e.key === 'Enter') runTailscaleScan();