feat(atlas): persist API tokens in localStorage across reloads
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d85cfbe1be
commit
538cbc582c
20
index.html
20
index.html
|
|
@ -2306,6 +2306,26 @@ function bindEvents() {
|
||||||
location.reload();
|
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('btnTailscaleScan').addEventListener('click', runTailscaleScan);
|
||||||
document.getElementById('tailscale-token-input').addEventListener('keydown', e => {
|
document.getElementById('tailscale-token-input').addEventListener('keydown', e => {
|
||||||
if (e.key === 'Enter') runTailscaleScan();
|
if (e.key === 'Enter') runTailscaleScan();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue