From e92ce752251b107423ff945a10a23abce867c5b3 Mon Sep 17 00:00:00 2001 From: Zephyruso <127948745+Zephyruso@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:08:35 +0800 Subject: [PATCH] feat: config for delay test --- src/i18n/en.ts | 1 + src/i18n/zh.ts | 1 + src/pages/Config.tsx | 62 ++++++++++++++++++++++++++---------------- src/signals/proxies.ts | 3 +- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 2e1c4b9..4d9f6da 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -38,4 +38,5 @@ export default { bar: 'Bar', auto: 'Auto', proxiesPreviewType: 'Proxies preview type', + urlForDelayTest: 'Url for delay test', } diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts index a5b2b74..d5d93b2 100644 --- a/src/i18n/zh.ts +++ b/src/i18n/zh.ts @@ -38,4 +38,5 @@ export default { bar: '条形', auto: '自适应', proxiesPreviewType: '节点组预览样式', + urlForDelayTest: '测速链接', } diff --git a/src/pages/Config.tsx b/src/pages/Config.tsx index c1dbba0..7800a04 100644 --- a/src/pages/Config.tsx +++ b/src/pages/Config.tsx @@ -132,36 +132,52 @@ export const [proxiesPreviewType, setProxiesPreviewType] = makePersisted( createSignal(PROXIES_PREVIEW_TYPE.BAR), { name: 'proxiesPreviewType', storage: localStorage }, ) +export const [urlForDelayTest, setUrlForDelayTest] = makePersisted( + createSignal('https://www.gstatic.com/generate_204'), + { name: 'urlForDelayTest', storage: localStorage }, +) -export default () => { +const ConfigForXd = () => { const [t] = useI18n() + return ( + <> +
{t('proxiesPreviewType')}
+
+ + {(value) => ( + + )} + +
+
{t('urlForDelayTest')}
+
+ setUrlForDelayTest(e.target?.value!)} + /> +
+ + ) +} + +export default () => { return (
- - -
-
{t('proxiesPreviewType')}
-
- - {(value) => ( - - )} - -
-
+
) } diff --git a/src/signals/proxies.ts b/src/signals/proxies.ts index f491ef4..13717a2 100644 --- a/src/signals/proxies.ts +++ b/src/signals/proxies.ts @@ -1,4 +1,5 @@ import { createSignal } from 'solid-js' +import { urlForDelayTest } from '~/pages/Config' import { useRequest } from '~/signals' import type { Proxy, ProxyNode, ProxyProvider } from '~/types' @@ -86,7 +87,7 @@ export function useProxies() { const data: Record = await request .get(`group/${proxyGroupName}/delay`, { searchParams: { - url: 'https://www.gstatic.com/generate_204', + url: urlForDelayTest(), timeout: 2000, }, })