Browse Source

NDS增加同步操作

main
dark 5 months ago
parent
commit
fbfc5ecdf3
  1. 13
      src/pages/websites/ssl/dns/DNSList.tsx
  2. 5
      src/service/websites.ts
  3. 13
      src/store/websites/dns.ts

13
src/pages/websites/ssl/dns/DNSList.tsx

@ -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'
@ -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,13 +207,20 @@ 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'} key={'del_confirm'}
disabled={isDeleting}
disabled={isDeleting || record.status === 2}
onConfirm={() => { onConfirm={() => {
deleteDNS(record.id) deleteDNS(record.id)
}} }}
@ -245,6 +253,7 @@ const DNSList = () => {
headerTitle={ headerTitle={
<Button <Button
onClick={() => { onClick={() => {
form.resetFields()
form.setFieldsValue({ form.setFieldsValue({
id: 0, id: 0,
type: DNSTypeEnum.DnsPod, type: DNSTypeEnum.DnsPod,

5
src/service/websites.ts

@ -16,7 +16,10 @@ const websitesServ = {
...createCURD<any, WebSite.IAcmeAccount>('/website/acme') ...createCURD<any, WebSite.IAcmeAccount>('/website/acme')
}, },
dns: { dns: {
...createCURD<any, WebSite.IDnsAccount>('/website/dns_account')
...createCURD<any, WebSite.IDnsAccount>('/website/dns_account'),
sync: async (params: WebSite.IDnsAccount) => {
return request.post<any, WebSite.IDnsAccount>('/website/dns_account/sync', params)
}
}, },
ca: { ca: {
...createCURD<any, WebSite.ICA>('/website/ca'), ...createCURD<any, WebSite.ICA>('/website/ca'),

13
src/store/websites/dns.ts

@ -100,3 +100,16 @@ export const deleteDNSAtom = atomWithMutation<IApiResult, number>(get => ({
get(dnsListAtom).refetch() get(dnsListAtom).refetch()
} }
})) }))
//sync
export const syncDNSAtom = atomWithMutation<IApiResult, number>(get => ({
mutationKey: [ 'syncDNS' ],
mutationFn: async (id) => {
return await websitesServ.dns.sync(id)
},
onSuccess: () => {
message.success(t('message.syncSuccess', '同步中'))
get(dnsListAtom).refetch()
}
}))
Loading…
Cancel
Save