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