import { t } from '../i18n.js'; import { logger } from '../utils/logger.js'; export async function initLicense() { const status = await checkLicenseStatus(); // Update global state state.license = { level: status.valid ? status.data.level : t('trial_community'), valid: status.valid, data: status.data || {} }; updateLicenseUI(status); } export async function checkLicenseStatus() { try { const res = await fetch('/api/license/status'); if (res.ok) { return await res.json(); } } catch (err) { logger.error("Failed to check license status", err); } return { valid: false, hwid: 'N/A' }; } export function updateLicenseUI(status) { const badge = document.querySelector('.logo-area span'); if (badge) { if (status.valid) { badge.textContent = status.data.level.toUpperCase(); badge.style.background = status.data.level === 'Enterprise' ? '#8b5cf6' : '#10b981'; } else { badge.textContent = 'UNLICENSED'; badge.style.background = '#ef4444'; } } } export async function showLicenseModal() { const status = await checkLicenseStatus(); const { showModal } = await import('./window.js'); const content = `
${status.hwid}
${t('hwid_copy_hint')}