|
|
@ -10,7 +10,7 @@ import { |
|
|
|
dnsPageAtom, |
|
|
|
DNSTypeEnum, |
|
|
|
DNSTypes, |
|
|
|
saveOrUpdateDNSAtom |
|
|
|
saveOrUpdateDNSAtom, syncDNSAtom |
|
|
|
} from '@/store/websites/dns.ts' |
|
|
|
import { WebSite } from '@/types' |
|
|
|
|
|
|
@ -74,20 +74,20 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
} |
|
|
|
case DNSTypeEnum.CloudFlare: { |
|
|
|
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 |
|
|
|
} |
|
|
@ -95,12 +95,12 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
case DNSTypeEnum.NameCheap: |
|
|
|
case DNSTypeEnum.NameSilo: |
|
|
|
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) { |
|
|
|
columns.push({ |
|
|
@ -122,20 +122,20 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
break |
|
|
|
case DNSTypeEnum.NameCom: { |
|
|
|
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 |
|
|
|
} |
|
|
@ -154,6 +154,7 @@ const DNSList = () => { |
|
|
|
const { data, isLoading, isFetching, refetch } = useAtomValue(dnsListAtom) |
|
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateDNSAtom) |
|
|
|
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom) |
|
|
|
const { mutate: asyncDNS, isPending: isAsyncing } = useAtomValue(syncDNSAtom) |
|
|
|
const [ open, setOpen ] = useState(false) |
|
|
|
|
|
|
|
const columns = useMemo<ProColumns<WebSite.IDnsAccount>[]>(() => { |
|
|
@ -206,17 +207,24 @@ const DNSList = () => { |
|
|
|
return [ |
|
|
|
<Action key="edit" |
|
|
|
as={'a'} |
|
|
|
disabled={record.status === 2} |
|
|
|
onClick={() => { |
|
|
|
form.setFieldsValue(record) |
|
|
|
setOpen(true) |
|
|
|
}}>{t('actions.edit')}</Action>, |
|
|
|
<Action key="sync" |
|
|
|
as={'a'} |
|
|
|
disabled={isAsyncing || record.status === 2} |
|
|
|
onClick={() => { |
|
|
|
asyncDNS(record) |
|
|
|
}}>{t('actions.sync', '同步')}</Action>, |
|
|
|
<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"> |
|
|
|
{t('actions.delete', '删除')} |
|
|
|
</a> |
|
|
@ -234,75 +242,76 @@ const DNSList = () => { |
|
|
|
}, [ isSuccess ]) |
|
|
|
|
|
|
|
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[]}/> |
|
|
|
</> |
|
|
|
) |
|
|
|
} |
|
|
|
|