From 3257791dec6851cb02cb627cbba469bf93d9ad90 Mon Sep 17 00:00:00 2001 From: Zephyruso <127948745+Zephyruso@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:25:22 +0800 Subject: [PATCH] feat: preview by auto --- src/components/ProxyNodePreview.tsx | 25 ++++++++++++++-- src/components/ProxyPreviewBar.tsx | 11 ++++---- src/config/enum.ts | 1 + src/i18n/en.ts | 4 +++ src/i18n/zh.ts | 4 +++ src/pages/Config.tsx | 44 +++++++++++++---------------- 6 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/components/ProxyNodePreview.tsx b/src/components/ProxyNodePreview.tsx index 0d7df7ba..5d9b2997 100644 --- a/src/components/ProxyNodePreview.tsx +++ b/src/components/ProxyNodePreview.tsx @@ -1,16 +1,35 @@ -import { Show } from 'solid-js' +import { Show, createMemo } from 'solid-js' import { PROXIES_PREVIEW_TYPE } from '~/config/enum' import { proxiesPreviewType } from '~/pages/Config' import ProxyPreviewBar from './ProxyPreviewBar' import ProxyPreviewDots from './ProxyPreviewDots' export default (props: { proxyNameList: string[]; now?: string }) => { + const isSmallGroup = createMemo(() => props.proxyNameList.length <= 30) + const isShowBar = createMemo(() => { + const type = proxiesPreviewType() + + return ( + type === PROXIES_PREVIEW_TYPE.BAR || + (type === PROXIES_PREVIEW_TYPE.Auto && !isSmallGroup()) + ) + }) + + const isShowDots = createMemo(() => { + const type = proxiesPreviewType() + + return ( + type === PROXIES_PREVIEW_TYPE.BAR || + (type === PROXIES_PREVIEW_TYPE.Auto && isSmallGroup()) + ) + }) + return ( <> - + - + diff --git a/src/components/ProxyPreviewBar.tsx b/src/components/ProxyPreviewBar.tsx index d15d8b08..0bcfdb46 100644 --- a/src/components/ProxyPreviewBar.tsx +++ b/src/components/ProxyPreviewBar.tsx @@ -1,5 +1,4 @@ import { createMemo } from 'solid-js' -import { twMerge } from 'tailwind-merge' import Delay from '~/components/Delay' import { DELAY } from '~/config/enum' import { useProxies } from '~/signals/proxies' @@ -32,28 +31,28 @@ export default (props: { proxyNameList: string[]; now?: string }) => { ) return ( -
+
{ + const [t] = useI18n() + return (
@@ -141,31 +143,23 @@ export default () => {
-
Proxies preview type:
- -
- - +
{t('proxiesPreviewType')}
+
+ + {(value) => ( + + )} +