refactor: dns query button

This commit is contained in:
kunish 2023-09-03 02:22:38 +08:00
parent 8e5654332d
commit 737378ac74
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
2 changed files with 18 additions and 17 deletions

View File

@ -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'])

View File

@ -35,7 +35,8 @@ 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 }), extend: validator({ schema: dnsQueryFormSchema }),
onSubmit: async (values) => { onSubmit: async (values) => {
request request
@ -47,7 +48,8 @@ const DNSQueryForm = () => {
setDNSQueryResult(Answer?.map(({ data }) => data) || []), 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>