const API_BASE = typeof window !== 'undefined' && window.API_BASE ? window.API_BASE : 'http://127.0.0.1:3001';
class SiteFooter extends HTMLElement {
connectedCallback() {
if (this._initialized) return;
this._initialized = true;
this.className = 'site-footer';
this.innerHTML = `
<div class="footer-inner">
<span class="footer-version" aria-label="アプリバージョン">v...</span>
<span>© 2026 DtmOjaji</span>
</div>
`;
this._fetchVersion();
}
async _fetchVersion() {
const el = this.querySelector('.footer-version');
if (!el) return;
try {
const res = await fetch(`${API_BASE}/version`);
const data = await res.json();
if (data && typeof data.version === 'string') {
el.textContent = `v${data.version}`;
}
} catch {
el.textContent = 'v?';
}
}
}
customElements.define('site-footer', SiteFooter);