import { useI18n } from '@solid-primitives/i18n'
import { A, useLocation, useNavigate } from '@solidjs/router'
import {
IconArrowsExchange,
IconFileStack,
IconGlobe,
IconGlobeFilled,
IconHome,
IconLanguage,
IconMenu,
IconNetwork,
IconPalette,
IconRuler,
IconSettings,
} from '@tabler/icons-solidjs'
import {
For,
ParentComponent,
Show,
createMemo,
createSignal,
onMount,
} from 'solid-js'
import { twMerge } from 'tailwind-merge'
import { LANG, ROUTE } from '~/config/enum'
import { themes } from '~/constants'
import { setCurTheme, setSelectedEndpoint } from '~/signals'
import { useProxies } from '~/signals/proxies'
const Nav: ParentComponent<{ href: string; tooltip: string }> = ({
href,
tooltip,
children,
}) => (
{children}
)
const ThemeSwitcher = () => (
)
export const Header = () => {
const [t, { locale }] = useI18n()
const { updateProxy, proxyProviders } = useProxies()
onMount(() => {
updateProxy()
})
const navs = createMemo(() => {
const list = [
{
href: ROUTE.Overview,
name: t('overview'),
icon: ,
},
{
href: ROUTE.Proxies,
name: t('proxies'),
icon: ,
},
{
href: ROUTE.Rules,
name: t('rules'),
icon: ,
},
{
href: ROUTE.Conns,
name: t('connections'),
icon: ,
},
{
href: ROUTE.Log,
name: t('logs'),
icon: ,
},
{
href: ROUTE.Config,
name: t('config'),
icon: ,
},
]
if (proxyProviders().length > 0) {
list.splice(2, 0, {
href: ROUTE.Proxyprovider,
name: t('proxyProviders'),
icon: ,
})
}
return list
})
const location = useLocation()
const navigate = useNavigate()
const [openedDrawer, setOpenedDrawer] = createSignal(false)
const onSwitchEndpointClick = () => {
setSelectedEndpoint('')
navigate('/setup')
}
return (
)
}