import { createForm } from '@felte/solid' import { validator } from '@felte/validator-zod' import { useI18n } from '@solid-primitives/i18n' import { makePersisted } from '@solid-primitives/storage' import { For, Show, createSignal, onMount } from 'solid-js' import { z } from 'zod' import { PROXIES_PREVIEW_TYPE } from '~/config/enum' import { useRequest } from '~/signals' import type { DNSQuery, Config as IConfig } from '~/types' const dnsQueryFormSchema = z.object({ name: z.string(), type: z.string(), }) const DNSQueryForm = () => { const [t] = useI18n() const request = useRequest() const { form } = createForm>({ extend: validator({ schema: dnsQueryFormSchema }), onSubmit: async (values) => { request .get('dns/query', { searchParams: { name: values.name, type: values.type }, }) .json() .then(({ Answer }) => setDNSQueryResult(Answer?.map(({ data }) => data) || []), ) }, }) const [DNSQueryResult, setDNSQueryResult] = createSignal([]) return (
0}>
{(item) =>
{item}
}
) } const configFormSchema = z.object({ port: z.number(), 'socks-port': z.number(), 'redir-port': z.number(), 'tproxy-port': z.number(), 'mixed-port': z.number(), }) const ConfigForm = () => { const request = useRequest() 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< z.infer >({ extend: validator({ schema: configFormSchema }) }) onMount(async () => { const configs = await request.get('configs').json() setInitialValues(configs) reset() }) return (
{(item) => (
)}
) } export const [proxiesPreviewType, setProxiesPreviewType] = makePersisted( createSignal(PROXIES_PREVIEW_TYPE.BAR), { name: 'proxiesPreviewType', storage: localStorage }, ) export default () => { return (
Proxies preview type:
) }