|
@ -10,7 +10,7 @@ import { |
|
|
dnsPageAtom, |
|
|
dnsPageAtom, |
|
|
DNSTypeEnum, |
|
|
DNSTypeEnum, |
|
|
DNSTypes, |
|
|
DNSTypes, |
|
|
saveOrUpdateDNSAtom |
|
|
|
|
|
|
|
|
saveOrUpdateDNSAtom, syncDNSAtom |
|
|
} from '@/store/websites/dns.ts' |
|
|
} from '@/store/websites/dns.ts' |
|
|
import { WebSite } from '@/types' |
|
|
import { WebSite } from '@/types' |
|
|
|
|
|
|
|
@ -74,20 +74,20 @@ const getKeyColumn = (type: string, t) => { |
|
|
} |
|
|
} |
|
|
case DNSTypeEnum.CloudFlare: { |
|
|
case DNSTypeEnum.CloudFlare: { |
|
|
columns.push(...[ |
|
|
columns.push(...[ |
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.email', 'Email'), |
|
|
|
|
|
dataIndex: 'email', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, { |
|
|
|
|
|
title: t('website.ssl.dns.columns.apiKey', 'API ToKen'), |
|
|
|
|
|
dataIndex: 'apiKey', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.email', 'Email'), |
|
|
|
|
|
dataIndex: 'email', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, { |
|
|
|
|
|
title: t('website.ssl.dns.columns.apiKey', 'API ToKen'), |
|
|
|
|
|
dataIndex: 'apiKey', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
) |
|
|
) |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
@ -95,12 +95,12 @@ const getKeyColumn = (type: string, t) => { |
|
|
case DNSTypeEnum.NameCheap: |
|
|
case DNSTypeEnum.NameCheap: |
|
|
case DNSTypeEnum.NameSilo: |
|
|
case DNSTypeEnum.NameSilo: |
|
|
columns.push({ |
|
|
columns.push({ |
|
|
title: t('website.ssl.dns.columns.apiKey', 'API Key'), |
|
|
|
|
|
dataIndex: 'apiKey', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
title: t('website.ssl.dns.columns.apiKey', 'API Key'), |
|
|
|
|
|
dataIndex: 'apiKey', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
) |
|
|
) |
|
|
if (type === DNSTypeEnum.NameCheap) { |
|
|
if (type === DNSTypeEnum.NameCheap) { |
|
|
columns.push({ |
|
|
columns.push({ |
|
@ -122,20 +122,20 @@ const getKeyColumn = (type: string, t) => { |
|
|
break |
|
|
break |
|
|
case DNSTypeEnum.NameCom: { |
|
|
case DNSTypeEnum.NameCom: { |
|
|
columns.push( |
|
|
columns.push( |
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.apiUser', 'UserName'), |
|
|
|
|
|
dataIndex: 'apiUser', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.token', 'Token'), |
|
|
|
|
|
dataIndex: 'token', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.apiUser', 'UserName'), |
|
|
|
|
|
dataIndex: 'apiUser', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: t('website.ssl.dns.columns.token', 'Token'), |
|
|
|
|
|
dataIndex: 'token', |
|
|
|
|
|
formItemProps: { |
|
|
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
) |
|
|
) |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
@ -154,6 +154,7 @@ const DNSList = () => { |
|
|
const { data, isLoading, isFetching, refetch } = useAtomValue(dnsListAtom) |
|
|
const { data, isLoading, isFetching, refetch } = useAtomValue(dnsListAtom) |
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateDNSAtom) |
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateDNSAtom) |
|
|
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom) |
|
|
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom) |
|
|
|
|
|
const { mutate: asyncDNS, isPending: isAsyncing } = useAtomValue(syncDNSAtom) |
|
|
const [ open, setOpen ] = useState(false) |
|
|
const [ open, setOpen ] = useState(false) |
|
|
|
|
|
|
|
|
const columns = useMemo<ProColumns<WebSite.IDnsAccount>[]>(() => { |
|
|
const columns = useMemo<ProColumns<WebSite.IDnsAccount>[]>(() => { |
|
@ -206,17 +207,24 @@ const DNSList = () => { |
|
|
return [ |
|
|
return [ |
|
|
<Action key="edit" |
|
|
<Action key="edit" |
|
|
as={'a'} |
|
|
as={'a'} |
|
|
|
|
|
disabled={record.status === 2} |
|
|
onClick={() => { |
|
|
onClick={() => { |
|
|
form.setFieldsValue(record) |
|
|
form.setFieldsValue(record) |
|
|
setOpen(true) |
|
|
setOpen(true) |
|
|
}}>{t('actions.edit')}</Action>, |
|
|
}}>{t('actions.edit')}</Action>, |
|
|
|
|
|
<Action key="sync" |
|
|
|
|
|
as={'a'} |
|
|
|
|
|
disabled={isAsyncing || record.status === 2} |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
asyncDNS(record) |
|
|
|
|
|
}}>{t('actions.sync', '同步')}</Action>, |
|
|
<Popconfirm |
|
|
<Popconfirm |
|
|
key={'del_confirm'} |
|
|
|
|
|
disabled={isDeleting} |
|
|
|
|
|
onConfirm={() => { |
|
|
|
|
|
deleteDNS(record.id) |
|
|
|
|
|
}} |
|
|
|
|
|
title={t('message.deleteConfirm')}> |
|
|
|
|
|
|
|
|
key={'del_confirm'} |
|
|
|
|
|
disabled={isDeleting || record.status === 2} |
|
|
|
|
|
onConfirm={() => { |
|
|
|
|
|
deleteDNS(record.id) |
|
|
|
|
|
}} |
|
|
|
|
|
title={t('message.deleteConfirm')}> |
|
|
<a key="del"> |
|
|
<a key="del"> |
|
|
{t('actions.delete', '删除')} |
|
|
{t('actions.delete', '删除')} |
|
|
</a> |
|
|
</a> |
|
@ -234,75 +242,76 @@ const DNSList = () => { |
|
|
}, [ isSuccess ]) |
|
|
}, [ isSuccess ]) |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
|
|
|
<ProTable<WebSite.IDnsAccount> |
|
|
|
|
|
cardProps={{ |
|
|
|
|
|
bodyStyle: { |
|
|
|
|
|
padding: 0, |
|
|
|
|
|
} |
|
|
|
|
|
}} |
|
|
|
|
|
rowKey="id" |
|
|
|
|
|
headerTitle={ |
|
|
|
|
|
<Button |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
form.setFieldsValue({ |
|
|
|
|
|
id: 0, |
|
|
|
|
|
type: DNSTypeEnum.DnsPod, |
|
|
|
|
|
}) |
|
|
|
|
|
setOpen(true) |
|
|
|
|
|
}} |
|
|
|
|
|
type={'primary'}>{t('website.ssl.dns.add', '添加DNS帐户')}</Button> |
|
|
|
|
|
} |
|
|
|
|
|
loading={isLoading || isFetching} |
|
|
|
|
|
dataSource={data?.rows ?? []} |
|
|
|
|
|
columns={columns} |
|
|
|
|
|
search={false} |
|
|
|
|
|
options={{ |
|
|
|
|
|
reload: () => { |
|
|
|
|
|
refetch() |
|
|
|
|
|
}, |
|
|
|
|
|
}} |
|
|
|
|
|
pagination={{ |
|
|
|
|
|
total: data?.total, |
|
|
|
|
|
pageSize: page.pageSize, |
|
|
|
|
|
current: page.page, |
|
|
|
|
|
onChange: (current, pageSize) => { |
|
|
|
|
|
setPage(prev => { |
|
|
|
|
|
return { |
|
|
|
|
|
...prev, |
|
|
|
|
|
page: current, |
|
|
|
|
|
pageSize: pageSize, |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
<> |
|
|
|
|
|
<ProTable<WebSite.IDnsAccount> |
|
|
|
|
|
cardProps={{ |
|
|
|
|
|
bodyStyle: { |
|
|
|
|
|
padding: 0, |
|
|
|
|
|
} |
|
|
|
|
|
}} |
|
|
|
|
|
rowKey="id" |
|
|
|
|
|
headerTitle={ |
|
|
|
|
|
<Button |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
form.resetFields() |
|
|
|
|
|
form.setFieldsValue({ |
|
|
|
|
|
id: 0, |
|
|
|
|
|
type: DNSTypeEnum.DnsPod, |
|
|
|
|
|
}) |
|
|
|
|
|
setOpen(true) |
|
|
|
|
|
}} |
|
|
|
|
|
type={'primary'}>{t('website.ssl.dns.add', '添加DNS帐户')}</Button> |
|
|
|
|
|
} |
|
|
|
|
|
loading={isLoading || isFetching} |
|
|
|
|
|
dataSource={data?.rows ?? []} |
|
|
|
|
|
columns={columns} |
|
|
|
|
|
search={false} |
|
|
|
|
|
options={{ |
|
|
|
|
|
reload: () => { |
|
|
|
|
|
refetch() |
|
|
|
|
|
}, |
|
|
|
|
|
}} |
|
|
|
|
|
pagination={{ |
|
|
|
|
|
total: data?.total, |
|
|
|
|
|
pageSize: page.pageSize, |
|
|
|
|
|
current: page.page, |
|
|
|
|
|
onChange: (current, pageSize) => { |
|
|
|
|
|
setPage(prev => { |
|
|
|
|
|
return { |
|
|
|
|
|
...prev, |
|
|
|
|
|
page: current, |
|
|
|
|
|
pageSize: pageSize, |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
<BetaSchemaForm<WebSite.IDnsAccount> |
|
|
|
|
|
shouldUpdate={false} |
|
|
|
|
|
width={600} |
|
|
|
|
|
form={form} |
|
|
|
|
|
layout={'horizontal'} |
|
|
|
|
|
scrollToFirstError={true} |
|
|
|
|
|
title={t(`website.ssl.dns.title_${form.getFieldValue('id') !== 0 ? 'edit' : 'add'}`, form.getFieldValue('id') !== 0 ? 'DNS帐号编辑' : 'DNS帐号添加')} |
|
|
|
|
|
// colProps={{ span: 24 }}
|
|
|
|
|
|
labelCol={{ span: 6 }} |
|
|
|
|
|
wrapperCol={{ span: 14 }} |
|
|
|
|
|
layoutType={'ModalForm'} |
|
|
|
|
|
open={open} |
|
|
|
|
|
modalProps={{ |
|
|
|
|
|
maskClosable: false, |
|
|
|
|
|
}} |
|
|
|
|
|
onOpenChange={(open) => { |
|
|
|
|
|
setOpen(open) |
|
|
|
|
|
}} |
|
|
|
|
|
loading={isSubmitting} |
|
|
|
|
|
onFinish={async (values) => { |
|
|
|
|
|
// console.log('values', values)
|
|
|
|
|
|
saveOrUpdate(values) |
|
|
|
|
|
}} |
|
|
|
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
|
|
|
</> |
|
|
|
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
<BetaSchemaForm<WebSite.IDnsAccount> |
|
|
|
|
|
shouldUpdate={false} |
|
|
|
|
|
width={600} |
|
|
|
|
|
form={form} |
|
|
|
|
|
layout={'horizontal'} |
|
|
|
|
|
scrollToFirstError={true} |
|
|
|
|
|
title={t(`website.ssl.dns.title_${form.getFieldValue('id') !== 0 ? 'edit' : 'add'}`, form.getFieldValue('id') !== 0 ? 'DNS帐号编辑' : 'DNS帐号添加')} |
|
|
|
|
|
// colProps={{ span: 24 }}
|
|
|
|
|
|
labelCol={{ span: 6 }} |
|
|
|
|
|
wrapperCol={{ span: 14 }} |
|
|
|
|
|
layoutType={'ModalForm'} |
|
|
|
|
|
open={open} |
|
|
|
|
|
modalProps={{ |
|
|
|
|
|
maskClosable: false, |
|
|
|
|
|
}} |
|
|
|
|
|
onOpenChange={(open) => { |
|
|
|
|
|
setOpen(open) |
|
|
|
|
|
}} |
|
|
|
|
|
loading={isSubmitting} |
|
|
|
|
|
onFinish={async (values) => { |
|
|
|
|
|
// console.log('values', values)
|
|
|
|
|
|
saveOrUpdate(values) |
|
|
|
|
|
}} |
|
|
|
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
|
|
|
</> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|