feat: config for delay test

This commit is contained in:
Zephyruso 2023-09-02 15:08:35 +08:00
parent 40ae24f5fe
commit e92ce75225
4 changed files with 43 additions and 24 deletions

View File

@ -38,4 +38,5 @@ export default {
bar: 'Bar',
auto: 'Auto',
proxiesPreviewType: 'Proxies preview type',
urlForDelayTest: 'Url for delay test',
}

View File

@ -38,4 +38,5 @@ export default {
bar: '条形',
auto: '自适应',
proxiesPreviewType: '节点组预览样式',
urlForDelayTest: '测速链接',
}

View File

@ -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 (
<>
<div>{t('proxiesPreviewType')}</div>
<div class="flex">
<For each={Object.values(PROXIES_PREVIEW_TYPE)}>
{(value) => (
<label class="flex items-center">
{t(value)}
<input
class="radio m-4"
aria-label={value}
type="radio"
name="proxiesPreviewType"
checked={value === proxiesPreviewType()}
onChange={() => setProxiesPreviewType(value)}
/>
</label>
)}
</For>
</div>
<div>{t('urlForDelayTest')}</div>
<div>
<input
class="input input-bordered w-96"
value={urlForDelayTest()}
onChange={(e) => setUrlForDelayTest(e.target?.value!)}
/>
</div>
</>
)
}
export default () => {
return (
<div class="flex flex-col gap-4">
<DNSQueryForm />
<ConfigForm />
<div>
<div>{t('proxiesPreviewType')}</div>
<div class="flex">
<For each={Object.values(PROXIES_PREVIEW_TYPE)}>
{(value) => (
<label class="flex items-center">
{t(value)}
<input
class="radio m-4"
aria-label={value}
type="radio"
name="proxiesPreviewType"
checked={value === proxiesPreviewType()}
onChange={() => setProxiesPreviewType(value)}
/>
</label>
)}
</For>
</div>
</div>
<ConfigForXd />
</div>
)
}

View File

@ -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<string, number> = await request
.get(`group/${proxyGroupName}/delay`, {
searchParams: {
url: 'https://www.gstatic.com/generate_204',
url: urlForDelayTest(),
timeout: 2000,
},
})