import { Component, For, onMount, Show } from 'solid-js'
import { Link, Outlet, useLocation } from '@tanstack/solid-router'
import { RadioTower } from 'lucide-solid'
import { refreshMe } from '../../lib/auth'
import { permissions } from '../../lib/permissions'
import { ThemeToggle } from '../../components/ui'
interface NavItem {
to: string
idx: string
label: string
activePaths?: string[]
adminOnly?: boolean
}
const NAV: NavItem[] = [
{ to: '/', idx: '01', label: '概览' },
{ to: '/rooms', idx: '02', label: '房间' },
{ to: '/watch', idx: '03', label: '观看', activePaths: ['/watch', '/room'] },
{ to: '/publish', idx: '04', label: '推流' },
{ to: '/users', idx: '05', label: '用户', adminOnly: true },
]
export const Layout: Component = () => {
const location = useLocation()
onMount(async () => {
await refreshMe()
await permissions.refresh()
})
const isActive = (item: NavItem) => (item.activePaths ?? [item.to]).includes(location().pathname)
const navLinks = (h: string) => (
<>