From 538cbc582cec8b5222c015629abf1d67a8e0b7f6 Mon Sep 17 00:00:00 2001 From: posimai Date: Tue, 31 Mar 2026 09:24:54 +0900 Subject: [PATCH] feat(atlas): persist API tokens in localStorage across reloads Co-Authored-By: Claude Sonnet 4.6 --- index.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.html b/index.html index 18aab3f..029de2f 100644 --- a/index.html +++ b/index.html @@ -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();