feat(proxy): add back the render proxies in two columns option, closes #360

This commit is contained in:
kunish 2023-10-29 20:02:10 +08:00
parent 0de2010790
commit 62c0cd9a63
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
4 changed files with 41 additions and 10 deletions

View File

@ -9,11 +9,13 @@ import {
latencyTestTimeoutDuration, latencyTestTimeoutDuration,
proxiesOrderingType, proxiesOrderingType,
proxiesPreviewType, proxiesPreviewType,
renderProxiesInTwoColumns,
setAutoCloseConns, setAutoCloseConns,
setHideUnAvailableProxies, setHideUnAvailableProxies,
setLatencyTestTimeoutDuration, setLatencyTestTimeoutDuration,
setProxiesOrderingType, setProxiesOrderingType,
setProxiesPreviewType, setProxiesPreviewType,
setRenderProxiesInTwoColumns,
setUrlForLatencyTest, setUrlForLatencyTest,
setUrlIPv6SupportTest, setUrlIPv6SupportTest,
urlForIPv6SupportTest, urlForIPv6SupportTest,
@ -113,6 +115,19 @@ export const ProxiesSettingsModal: Component<{
</div> </div>
</div> </div>
<div>
<ConfigTitle withDivider>{t('renderInTwoColumns')}</ConfigTitle>
<div class="flex w-full justify-center">
<input
class="toggle"
type="checkbox"
checked={renderProxiesInTwoColumns()}
onChange={(e) => setRenderProxiesInTwoColumns(e.target.checked)}
/>
</div>
</div>
<div> <div>
<ConfigTitle withDivider>{t('proxiesPreviewType')}</ConfigTitle> <ConfigTitle withDivider>{t('proxiesPreviewType')}</ConfigTitle>

View File

@ -42,27 +42,27 @@ export const ProxyPreviewBar = (props: {
return ( return (
<div class="flex items-center gap-2 py-2"> <div class="flex items-center gap-2 py-2">
<div class="flex flex-1 overflow-hidden rounded-2xl"> <div class="flex h-4 flex-1 items-center justify-center">
<div <div
class="h-2 bg-success" class="h-2 overflow-hidden rounded-2xl bg-success"
style={{ style={{
width: `${(good() * 100) / all()}%`, // cant use tw class, otherwise dynamic classname won't be generated width: `${(good() * 100) / all()}%`, // cant use tw class, otherwise dynamic classname won't be generated
}} }}
/> />
<div <div
class="h-2 bg-warning" class="h-2 overflow-hidden rounded-2xl bg-warning"
style={{ style={{
width: `${(middle() * 100) / all()}%`, width: `${(middle() * 100) / all()}%`,
}} }}
/> />
<div <div
class="h-2 bg-error" class="h-2 overflow-hidden rounded-2xl bg-error"
style={{ style={{
width: `${(slow() * 100) / all()}%`, width: `${(slow() * 100) / all()}%`,
}} }}
/> />
<div <div
class="h-2 bg-neutral" class="h-2 overflow-hidden rounded-2xl bg-neutral"
style={{ style={{
width: `${(notConnected() * 100) / all()}%`, width: `${(notConnected() * 100) / all()}%`,
}} }}

View File

@ -11,7 +11,6 @@ import {
ProxiesSettingsModal, ProxiesSettingsModal,
ProxyNodeCard, ProxyNodeCard,
ProxyNodePreview, ProxyNodePreview,
RenderInTwoColumns,
SubscriptionInfo, SubscriptionInfo,
} from '~/components' } from '~/components'
import { import {
@ -23,6 +22,7 @@ import {
formatTimeFromNow, formatTimeFromNow,
hideUnAvailableProxies, hideUnAvailableProxies,
proxiesOrderingType, proxiesOrderingType,
renderProxiesInTwoColumns,
useProxies, useProxies,
} from '~/signals' } from '~/signals'
@ -143,7 +143,12 @@ export default () => {
<div class="flex-1 overflow-y-auto"> <div class="flex-1 overflow-y-auto">
<Show when={activeTab() === ActiveTab.proxies}> <Show when={activeTab() === ActiveTab.proxies}>
<RenderInTwoColumns> <div
class={twMerge(
'grid grid-cols-1 place-items-start gap-2',
renderProxiesInTwoColumns() ? 'sm:grid-cols-2' : 'sm:grid-cols-1',
)}
>
<For each={proxies()}> <For each={proxies()}>
{(proxyGroup) => { {(proxyGroup) => {
const sortedProxyNames = createMemo(() => const sortedProxyNames = createMemo(() =>
@ -222,11 +227,16 @@ export default () => {
) )
}} }}
</For> </For>
</RenderInTwoColumns> </div>
</Show> </Show>
<Show when={activeTab() === ActiveTab.proxyProviders}> <Show when={activeTab() === ActiveTab.proxyProviders}>
<RenderInTwoColumns> <div
class={twMerge(
'grid grid-cols-1 place-items-start gap-2',
renderProxiesInTwoColumns() ? 'sm:grid-cols-2' : 'sm:grid-cols-1',
)}
>
<For each={proxyProviders()}> <For each={proxyProviders()}>
{(proxyProvider) => { {(proxyProvider) => {
const sortedProxyNames = createMemo(() => const sortedProxyNames = createMemo(() =>
@ -318,7 +328,7 @@ export default () => {
) )
}} }}
</For> </For>
</RenderInTwoColumns> </div>
</Show> </Show>
</div> </div>

View File

@ -32,6 +32,12 @@ export const [hideUnAvailableProxies, setHideUnAvailableProxies] =
storage: localStorage, storage: localStorage,
}) })
export const [renderProxiesInTwoColumns, setRenderProxiesInTwoColumns] =
makePersisted(createSignal(true), {
name: 'renderProxiesInTwoColumns',
storage: localStorage,
})
export const [urlForLatencyTest, setUrlForLatencyTest] = makePersisted( export const [urlForLatencyTest, setUrlForLatencyTest] = makePersisted(
createSignal('https://www.gstatic.com/generate_204'), createSignal('https://www.gstatic.com/generate_204'),
{ name: 'urlForLatencyTest', storage: localStorage }, { name: 'urlForLatencyTest', storage: localStorage },