function openModal(id) { const modal = document.getElementById(id); if (modal) modal.classList.remove('hidden'); } function closeModal(id) { const modal = document.getElementById(id); if (modal) modal.classList.add('hidden'); } function updateAuthUI() { const user = state.currentUser; const adminBanner = document.getElementById('admin-banner'); const btnManageSuppliers = document.getElementById('btn-manage-suppliers'); const btnFabAdd = document.getElementById('btn-fab-add'); const authIcon = document.getElementById('auth-icon'); const authLabel = document.getElementById('auth-label'); const userNameEl = document.getElementById('user-display-name'); const userRoleEl = document.getElementById('user-role-badge'); if (user) { if (adminBanner) adminBanner.classList.remove('hidden'); if (btnFabAdd) btnFabAdd.classList.remove('hidden'); if (userNameEl) userNameEl.textContent = user.displayName || user.username; if (userRoleEl) userRoleEl.textContent = user.role === 'admin' ? '总店管理员' : '专线供应商'; if (btnManageSuppliers) { if (user.role === 'admin') { btnManageSuppliers.classList.remove('hidden'); } else { btnManageSuppliers.classList.add('hidden'); } } if (authIcon) authIcon.className = "fa-solid fa-user-check text-rose-500 text-sm"; if (authLabel) authLabel.textContent = user.displayName || user.username; } else { if (adminBanner) adminBanner.classList.add('hidden'); if (btnFabAdd) btnFabAdd.classList.add('hidden'); if (btnManageSuppliers) btnManageSuppliers.classList.add('hidden'); if (authIcon) authIcon.className = "fa-solid fa-user-gear text-sm"; if (authLabel) authLabel.textContent = "管理登录"; } } function handleAuthButtonClick() { ``` ### Summary of Changes: - Added guard checks for `adminBanner`, `btnFabAdd`, `btnManageSuppliers`, `userNameEl`, `userRoleEl`, `authIcon`, and `authLabel` before manipulating `.classList` or `.textContent`. - Resolved the `TypeError: Cannot read properties of null` error during page initialization.