mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-23 21:35:36 +08:00
refactor: dns query button
This commit is contained in:
parent
8e5654332d
commit
737378ac74
@ -2,9 +2,7 @@ import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
export const Button: ParentComponent<
|
||||
JSX.HTMLAttributes<HTMLButtonElement> & {
|
||||
loading?: boolean
|
||||
}
|
||||
JSX.ButtonHTMLAttributes<HTMLButtonElement> & { loading?: boolean }
|
||||
> = (props) => {
|
||||
const [local, others] = splitProps(props, ['class', 'loading'])
|
||||
|
||||
|
@ -35,19 +35,21 @@ const DNSQueryForm = () => {
|
||||
const [t] = useI18n()
|
||||
const request = useRequest()
|
||||
|
||||
const { form } = createForm<z.infer<typeof dnsQueryFormSchema>>({
|
||||
extend: validator({ schema: dnsQueryFormSchema }),
|
||||
onSubmit: async (values) => {
|
||||
request
|
||||
.get('dns/query', {
|
||||
searchParams: { name: values.name, type: values.type },
|
||||
})
|
||||
.json<DNSQuery>()
|
||||
.then(({ Answer }) =>
|
||||
setDNSQueryResult(Answer?.map(({ data }) => data) || []),
|
||||
)
|
||||
const { form, isSubmitting } = createForm<z.infer<typeof dnsQueryFormSchema>>(
|
||||
{
|
||||
extend: validator({ schema: dnsQueryFormSchema }),
|
||||
onSubmit: async (values) => {
|
||||
request
|
||||
.get('dns/query', {
|
||||
searchParams: { name: values.name, type: values.type },
|
||||
})
|
||||
.json<DNSQuery>()
|
||||
.then(({ Answer }) =>
|
||||
setDNSQueryResult(Answer?.map(({ data }) => data) || []),
|
||||
)
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
const [DNSQueryResult, setDNSQueryResult] = createSignal<string[]>([])
|
||||
|
||||
@ -64,9 +66,10 @@ const DNSQueryForm = () => {
|
||||
<option>AAAA</option>
|
||||
<option>MX</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
|
||||
<Button type="submit" class="btn-primary" loading={isSubmitting()}>
|
||||
{t('dnsQuery')}
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user