import { createForm } from '@felte/solid' import { validator } from '@felte/validator-zod' import { For, Show, createSignal, onMount } from 'solid-js' import { z } from 'zod' import { useRequest } from '~/signals' import type { DNSQuery, Config as IConfig } from '~/types' const schema = z.object({ port: z.number(), 'socks-port': z.number(), 'redir-port': z.number(), 'tproxy-port': z.number(), 'mixed-port': z.number(), }) import { makePersisted } from '@solid-primitives/storage' import { PROXIES_PREVIEW_TYPE } from '~/config/enum' export const [proxiesPreviewType, setProxiesPreviewType] = makePersisted( createSignal(PROXIES_PREVIEW_TYPE.BAR), { name: 'proxiesPreviewType', storage: localStorage, }, ) export default () => { const request = useRequest() const [DNSQueryName, setDNSQueryName] = createSignal('') const [DNSQueryResult, setDNSQueryResult] = createSignal([]) const onDNSQuery = () => request .get('dns/query', { searchParams: { name: DNSQueryName(), }, }) .json() .then(({ Answer }) => { setDNSQueryResult(Answer.map(({ data }) => data)) }) const portsList = [ { label: 'Http Port', key: 'port', }, { label: 'Socks Port', key: 'socks-port', }, { label: 'Redir Port', key: 'redir-port', }, { label: 'Tproxy Port', key: 'tproxy-port', }, { label: 'Mixed Port', key: 'mixed-port', }, ] const { form, setInitialValues, reset } = createForm>({ extend: validator({ schema }), }) onMount(async () => { const configs = await request.get('configs').json() setInitialValues(configs) reset() }) return (
{ e.preventDefault() onDNSQuery() }} > setDNSQueryName(e.target.value)} />
0}>
{(item) =>
{item}
}
Proxies preview type:
{(item) => (
)}
) }