feat(proxies): default proxies and remove all tab

This commit is contained in:
Zephyruso 2023-09-07 13:09:27 +08:00
parent 44739f6962
commit 66c793550a

View File

@ -19,7 +19,6 @@ import { proxiesOrderingType, useProxies } from '~/signals'
import type { Proxy } from '~/types' import type { Proxy } from '~/types'
enum ActiveTab { enum ActiveTab {
all = 'all',
proxyProviders = 'proxyProviders', proxyProviders = 'proxyProviders',
proxies = 'proxies', proxies = 'proxies',
} }
@ -75,30 +74,26 @@ export default () => {
setIsAllProviderUpdating(false) setIsAllProviderUpdating(false)
} }
const [activeTab, setActiveTab] = createSignal(ActiveTab.all) const [activeTab, setActiveTab] = createSignal(ActiveTab.proxies)
const tabs = () => [ const tabs = () => [
{ {
type: ActiveTab.all, type: ActiveTab.proxies,
name: t('all'), name: t('proxies'),
count: proxyProviders().length + proxies().length, count: proxies().length,
}, },
{ {
type: ActiveTab.proxyProviders, type: ActiveTab.proxyProviders,
name: t('proxyProviders'), name: t('proxyProviders'),
count: proxyProviders().length, count: proxyProviders().length,
}, },
{
type: ActiveTab.proxies,
name: t('proxies'),
count: proxies().length,
},
] ]
return ( return (
<div class="flex h-full flex-col gap-2"> <div class="flex h-full flex-col gap-2">
<Show when={proxyProviders().length > 0}>
<div class="flex items-center justify-between gap-2"> <div class="flex items-center justify-between gap-2">
<div class="tabs tabs-boxed gap-2"> <div class="tabs-boxed tabs gap-2">
<For each={tabs()}> <For each={tabs()}>
{(tab) => ( {(tab) => (
<button <button
@ -115,6 +110,7 @@ export default () => {
</For> </For>
</div> </div>
<Show when={activeTab() === ActiveTab.proxyProviders}>
<Button <Button
class="btn btn-circle btn-sm" class="btn btn-circle btn-sm"
disabled={isAllProviderUpdating()} disabled={isAllProviderUpdating()}
@ -126,15 +122,12 @@ export default () => {
)} )}
/> />
</Button> </Button>
</Show>
</div> </div>
</Show>
<div class="flex-1 overflow-y-auto"> <div class="flex-1 overflow-y-auto">
<Show <Show when={activeTab() === ActiveTab.proxyProviders}>
when={
activeTab() === ActiveTab.all ||
activeTab() === ActiveTab.proxyProviders
}
>
<ForTwoColumns <ForTwoColumns
subChild={proxyProviders().map((proxyProvider) => { subChild={proxyProviders().map((proxyProvider) => {
const sortedProxyNames = sortProxiesByOrderingType( const sortedProxyNames = sortProxiesByOrderingType(
@ -215,15 +208,7 @@ export default () => {
/> />
</Show> </Show>
<Show when={activeTab() === ActiveTab.all}> <Show when={activeTab() === ActiveTab.proxies}>
<div class="divider" />
</Show>
<Show
when={
activeTab() === ActiveTab.all || activeTab() === ActiveTab.proxies
}
>
<ForTwoColumns <ForTwoColumns
subChild={proxies().map((proxy) => { subChild={proxies().map((proxy) => {
const sortedProxyNames = sortProxiesByOrderingType( const sortedProxyNames = sortProxiesByOrderingType(