import { applications, validateApplications } from './apps.mjs'; validateApplications(applications); const icons = { shield: '', scan: '', arrow: '', external: '' }; const svg = name => ``; const escapeHtml = value => String(value).replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); const grid = document.querySelector('#agent-grid'); const root = document.documentElement; const themeKey = 'dieya-portal:theme:v1'; const storedTheme = localStorage.getItem(themeKey); const preferredTheme = storedTheme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); function applyTheme(theme) { root.dataset.theme = theme; document.querySelectorAll('[data-theme]').forEach(button => { const active = button.dataset.theme === theme; button.classList.toggle('active', active); button.setAttribute('aria-pressed', String(active)); }); document.querySelector('meta[name="theme-color"]').setAttribute('content', theme === 'dark' ? '#070b17' : '#f5f8fc'); try { localStorage.setItem(themeKey, theme); } catch { /* 当前浏览器不支持持久化时仍可切换 */ } } function render() { grid.innerHTML = applications.map((app, index) => `
${svg(app.icon)}产品部

${escapeHtml(app.name)} 正式应用

${escapeHtml(app.description)}

就绪0${index + 1}
打开工作台 ${svg('arrow')}
`).join(''); document.querySelector('#empty-state').hidden = applications.length > 0; } document.querySelectorAll('[data-theme]').forEach(button => button.addEventListener('click', () => applyTheme(button.dataset.theme))); applyTheme(preferredTheme); render();