|
@ -1,11 +1,17 @@ |
|
|
import { useMemo, useState } from 'react' |
|
|
|
|
|
|
|
|
import { useEffect, useMemo, useState } from 'react' |
|
|
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components' |
|
|
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components' |
|
|
import { useTranslation } from '@/i18n.ts' |
|
|
import { useTranslation } from '@/i18n.ts' |
|
|
import { AcmeAccountTypes, acmeListAtom, acmePageAtom, AcmeType, saveOrUpdateAcmeAtom } from '@/store/websites/acme.ts' |
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
AcmeAccountTypes, |
|
|
|
|
|
acmeListAtom, |
|
|
|
|
|
acmePageAtom, |
|
|
|
|
|
AcmeType, |
|
|
|
|
|
deleteAcmeAtom, |
|
|
|
|
|
saveOrUpdateAcmeAtom |
|
|
|
|
|
} from '@/store/websites/acme.ts' |
|
|
import { useAtom, useAtomValue } from 'jotai' |
|
|
import { useAtom, useAtomValue } from 'jotai' |
|
|
import { Alert, Button, Form, Popconfirm } from 'antd' |
|
|
import { Alert, Button, Form, Popconfirm } from 'antd' |
|
|
import { KeyTypeEnum, KeyTypes } from '@/store/websites/ssl.ts' |
|
|
import { KeyTypeEnum, KeyTypes } from '@/store/websites/ssl.ts' |
|
|
import { deleteDNSAtom } from '@/store/websites/dns.ts' |
|
|
|
|
|
import { WebSite } from '@/types' |
|
|
import { WebSite } from '@/types' |
|
|
|
|
|
|
|
|
const AcmeList = () => { |
|
|
const AcmeList = () => { |
|
@ -13,9 +19,9 @@ const AcmeList = () => { |
|
|
const { t } = useTranslation() |
|
|
const { t } = useTranslation() |
|
|
const [ form ] = Form.useForm() |
|
|
const [ form ] = Form.useForm() |
|
|
const [ page, setPage ] = useAtom(acmePageAtom) |
|
|
const [ page, setPage ] = useAtom(acmePageAtom) |
|
|
const { data, isLoading, refetch } = useAtomValue(acmeListAtom) |
|
|
|
|
|
|
|
|
const { data, isLoading, isFetching, refetch } = useAtomValue(acmeListAtom) |
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateAcmeAtom) |
|
|
const { mutate: saveOrUpdate, isPending: isSubmitting, isSuccess } = useAtomValue(saveOrUpdateAcmeAtom) |
|
|
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom) |
|
|
|
|
|
|
|
|
const { mutate: deleteAcme, isPending: isDeleting } = useAtomValue(deleteAcmeAtom) |
|
|
const [ open, setOpen ] = useState(false) |
|
|
const [ open, setOpen ] = useState(false) |
|
|
|
|
|
|
|
|
const columns = useMemo<ProColumns<WebSite.IAcmeAccount>[]>(() => { |
|
|
const columns = useMemo<ProColumns<WebSite.IAcmeAccount>[]>(() => { |
|
@ -53,7 +59,7 @@ const AcmeList = () => { |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: t('website.ssl.acme.columns.keyType', '密钥算法'), |
|
|
title: t('website.ssl.acme.columns.keyType', '密钥算法'), |
|
|
dataIndex: 'keyType', |
|
|
|
|
|
|
|
|
dataIndex: 'key_type', |
|
|
valueType: 'select', |
|
|
valueType: 'select', |
|
|
fieldProps: { |
|
|
fieldProps: { |
|
|
options: KeyTypes |
|
|
options: KeyTypes |
|
@ -71,15 +77,16 @@ const AcmeList = () => { |
|
|
ellipsis: true, // 文本溢出省略
|
|
|
ellipsis: true, // 文本溢出省略
|
|
|
hideInForm: true, |
|
|
hideInForm: true, |
|
|
}, { |
|
|
}, { |
|
|
title: '操作', |
|
|
|
|
|
|
|
|
title: t('website.ssl.acme.columns.option', '操作'), |
|
|
valueType: 'option', |
|
|
valueType: 'option', |
|
|
|
|
|
fixed: 'right', |
|
|
render: (_, record) => { |
|
|
render: (_, record) => { |
|
|
return [ |
|
|
return [ |
|
|
<Popconfirm |
|
|
<Popconfirm |
|
|
key={'del_confirm'} |
|
|
key={'del_confirm'} |
|
|
disabled={isDeleting} |
|
|
disabled={isDeleting} |
|
|
onConfirm={() => { |
|
|
onConfirm={() => { |
|
|
deleteDNS(record.id) |
|
|
|
|
|
|
|
|
deleteAcme(record.id) |
|
|
}} |
|
|
}} |
|
|
title={t('message.deleteConfirm')}> |
|
|
title={t('message.deleteConfirm')}> |
|
|
<a key="del"> |
|
|
<a key="del"> |
|
@ -92,6 +99,12 @@ const AcmeList = () => { |
|
|
] |
|
|
] |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (isSuccess) { |
|
|
|
|
|
setOpen(false) |
|
|
|
|
|
} |
|
|
|
|
|
}, [ isSuccess ]) |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<Alert message={t('website.ssl.acme.tip', 'Acme账户用于申请免费证书')}/> |
|
|
<Alert message={t('website.ssl.acme.tip', 'Acme账户用于申请免费证书')}/> |
|
@ -114,7 +127,7 @@ const AcmeList = () => { |
|
|
}} |
|
|
}} |
|
|
type={'primary'}>{t('website.ssl.acme.add', '添加Acme帐户')}</Button> |
|
|
type={'primary'}>{t('website.ssl.acme.add', '添加Acme帐户')}</Button> |
|
|
} |
|
|
} |
|
|
loading={isLoading} |
|
|
|
|
|
|
|
|
loading={isLoading || isFetching} |
|
|
dataSource={data?.rows ?? []} |
|
|
dataSource={data?.rows ?? []} |
|
|
columns={columns} |
|
|
columns={columns} |
|
|
search={false} |
|
|
search={false} |
|
@ -161,7 +174,7 @@ const AcmeList = () => { |
|
|
onFinish={async (values) => { |
|
|
onFinish={async (values) => { |
|
|
// console.log('values', values)
|
|
|
// console.log('values', values)
|
|
|
saveOrUpdate(values) |
|
|
saveOrUpdate(values) |
|
|
return isSuccess |
|
|
|
|
|
|
|
|
|
|
|
}} |
|
|
}} |
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
</> |
|
|
</> |
|
|