import { useUIStore, type ViewMode } from '../stores/uiStore'; import { useMailStore } from '../stores/mailStore'; import { useContactStore } from '../stores/contactStore'; import { useAuthStore } from '../stores/authStore'; import { InboxIcon, SentIcon, ContactsIcon, ComposeIcon, UsersIcon, PersonIcon, ShieldIcon, CalendarIcon } from './icons'; import { ConnectionIndicator } from './ConnectionIndicator'; import { countPendingPermissions, splitByPermission } from '../lib/mailGroups'; /** * 窄屏底部导航。 * * 移动端把主导航放底部而不是顶部:拇指够得到。 * 宽屏用的是左侧竖条(Sidebar),两者共用 uiStore 的 viewMode, * 所以从窄拖到宽不会丢失当前位置。 * * 这里只放最常用的几项 + 一个「更多」入口(打开抽屉式 Sidebar)—— * 底部塞满图标会挤成一排看不懂的小方块。 */ const items: { short: string; mode: ViewMode; Icon: (p: { className?: string }) => JSX.Element; adminOnly?: boolean; }[] = [ { short: '收件', mode: 'inbox', Icon: InboxIcon }, { short: '授权', mode: 'permissions', Icon: ShieldIcon }, { short: '发件', mode: 'sent', Icon: SentIcon }, { short: '日历', mode: 'calendar', Icon: CalendarIcon }, { short: '联系人', mode: 'contacts', Icon: ContactsIcon }, { short: '管理', mode: 'admin', Icon: UsersIcon, adminOnly: true } ]; export default function NarrowNav() { const viewMode = useUIStore(s => s.viewMode); const setViewMode = useUIStore(s => s.setViewMode); const composing = useUIStore(s => s.composing); const startCompose = useUIStore(s => s.startCompose); const narrowPane = useUIStore(s => s.narrowPane); const inbox = useMailStore(s => s.inbox); // 与 Sidebar 同一判据:权限请求归「授权」,不算进收件箱未读 const { normal, permissions } = splitByPermission(inbox); const unread = normal.filter(m => m.status === 'unread').length; const pendingPerms = countPendingPermissions(permissions); const contacts = useContactStore(s => s.contacts); const user = useAuthStore(s => s.user); const isAdmin = user?.role === 'admin'; const visible = items.filter(n => !n.adminOnly || isAdmin); return ( ); }