'use client'; import { useState, useEffect } from 'react'; import { getSession, clearSession } from '@/lib/store/auth-store'; import { SettingsSection } from './SettingsSection'; import { LogOut, Shield, Info } from 'lucide-react'; export function AccountSettings() { const [session, setSessionState] = useState>(null); const [hasAuth, setHasAuth] = useState(false); useEffect(() => { setSessionState(getSession()); fetch('/api/auth') .then(res => res.json()) .then(data => setHasAuth(data.hasAuth)) .catch(() => {}); }, []); const handleLogout = () => { clearSession(); window.location.reload(); }; if (!hasAuth && !session) return null; return (
{/* Current User Info */} {session && (
{session.name.charAt(0)}

{session.name}

{session.role === 'admin' ? '管理员' : '观众'}
)} {/* Config Notice */}

账户通过环境变量配置:

ADMIN_PASSWORD — 单管理员密码

ACCOUNTS — 多账户(密码:名称[:角色])

); }